327 karma · joined March 20, 2019
That being said, I am pretty sure the self hosted models will get there very soon.
Are you looking to deploy a solution with a self-hosted model?
Do you have a specific use-case in mind? Would love to collaborate on adding it to the open-source library if you are open to it.
Additional color: Once you configure a connection to a DB, you can trigger a 'scan' of the DB through the API which detects various tables/columns, identifies low cardinality (categorical) columns and their values and also loads in VIEWS stored on tables. In our default NL2SQL agent, these are then used together with 'verified' NL2SQL pairs and with other metadata you can manually add to generate the SQL.
We are looking to automatically add context from Stored procedures and other sources like dbt and various data dictionaries as well.
The core engine works in three steps:
1- Extract intent and entities from the user prompt (the metric they want, date ranges and location)
2- Query structured data from various sources in our data warehouses
3- Construct the final text and accompanying data visualization.
In the first iterations we trained our model for the extraction step and used templated SQL with variables for entities in step 2. However with the release of GPT-4 and rapid development of LangChain we soon migrated to building on the LangChain framework and relying on GPT-4 to write SQL on the fly. From LangChain we use PromptTemplates, Memory, Example Selectors and Chains heavily. The three steps described above eventually became three chains we built and optimized.
Overall we love Langchain. It allowed us to release quickly and leverage abstractions which cleaned up our code. One of the best parts about building on LangChain is the active community on Discord. However it is a sprawling framework and some components still do not seem ready for use in production. For example, we gave up on using SQLAgent pretty early on since it failed some easy testing.
Some of the other challenges we faced: - GPT-4 is very slow and in our experience GPT3.5–turbo does not work well for building complex SQL queries on the fly. As a result the three chains currently take an average of 27s to produce an answer unless it is already cached.
- When working with SQL results and structured datasets, you quickly hit the token limit when passing the SQL results to the LLM. We did not have access to the 32K context window, so once that is rolled out this should be less of a concern.
- How to test? There does not seem to be many QA tools for LLM applications. We ended up building our own solutions to score generated content and flag low scores so we can add examples to our prompts.
Looking forward to the next few weeks, we plan on delivering the following:
1- Templates that allow users to create content that is optimized for blog posts and social media posts out of the box.
2- Fix some limitations in prompts we can handle. You currently can’t compare across geo types (city with national trends).
3- Add more datasets covering neighborhood level data.
4- Add more chart and map types and viz customization features
Would love to hear the community's thoughts. Are there tools or approaches that we should have considered? Does anyone use Langchain’s SQLAgent in production? Know any real estate professionals we should talk to?
Why was it hard?
- Unless you are AirBnB or Zillow, you will have a limited crawl budget. To get the most out of your budget with a high number of pages, you need to statically generate every single page in advance. Next.js (Vercel) and other static site generators make this easier than it was 5 years ago, but it is still quite a context switch if your entire front-end is a single page application.
- You can’t just drop a table, graph or a few lines of text on the page. Google will penalize your domain for creating spam, low quality content and your domain will be in the dog-house (bye bye organic traffic). The content has to be high quality and engaging for the visitor.
- If your data points will change over time (i.e the number of pages themselves are dynamic) you will have to automate your sitemap creation and maintenance
- You need data. This was the easiest part for us since collecting and organizing external data was our core business, but building and maintaining data pipelines is not easy in general.
How did we solve it?
- We already have millions of data points from pubic and private sources in our warehouse, so data availability wasn’t an issue
- Vercel on the front-end
- We took model driven approach to the backend architecture to allow us to create various front-end templates (HTML code displaying visuals, text, CTAs, etc) from our various data sources. The templates are JSON schema that define how to generate thousands or millions of landing pages. A service creates the pages and then updates them automatically on data source updates
- We are exploring various structured data to text AI solutions but still doing lots of manual templated text writing with SQL.
- Classic SEO optimizations on the page (Ahrefs research, meta tags, H1 tags, canonical, …)
What do you think?
- If the approach above sounds genius or stupid, we would love to hear from you
- If you know of a good structured data to text AI solution, email us
- If you want to implement programmatic SEO please reach out
Thanks for the feedback on the landing page. We will take it into account in the next iteration of the design.
- On the backend we can add new data pipelines to any public data by setting a few configuration parameters
- The front end is completely modular with re-usable D3 components
While we are doing the configuration ourselves for now, we plan to open this up over time.