|
| 1 | +--- |
| 2 | +description: How the best AI-powered app for fiction writers built their winning RAG stack |
| 3 | +featured: true |
| 4 | +tags: [] |
| 5 | +image: ".gitbook/assets/sudowrite-pgml_blog-image.png" |
| 6 | +--- |
| 7 | + |
| 8 | +# Sudowrite + PostgresML |
| 9 | + |
| 10 | +<div align="left"> |
| 11 | + |
| 12 | +<figure><img src=".gitbook/assets/image.png" alt="Author" width="100"><figcaption></figcaption></figure> |
| 13 | + |
| 14 | +</div> |
| 15 | + |
| 16 | +Cassandra Stummer |
| 17 | + |
| 18 | +August 26, 2024 |
| 19 | + |
| 20 | +## The challenge |
| 21 | + |
| 22 | +[Sudowrite](https://www.sudowrite.com/) is an AI-powered writing assistant that helps author's craft compelling stories and overcome writer's block. They wanted to give authors a cool new feature: the ability to chat with an AI editor about their stories. |
| 23 | + |
| 24 | +James Yu, Sudowrite’s founder and CTO, knew that meant standing up a RAG (retrieval augmented generation) system. RAG is a cutting-edge AI technique, but James was searching for a solution that worked in production and at-scale, not just in the latest prototype trending on Hacker News. |
| 25 | + |
| 26 | +“I didn’t want to geek out about RAG for days or weeks. Just give me something that approximately works and then I can move on to the next thing.” |
| 27 | + |
| 28 | +## Enter PostgresML |
| 29 | + |
| 30 | +PostgresML is simple – it’s PostgreSQL with GPUs for ML/AI apps. Along with GPUs, the PostgresML Cloud provides a full-featured machine learning platform right in the database; with functionality for search, embeddings, retrieval and more. |
| 31 | + |
| 32 | +James was sold on the simplicity of doing AI in Postgres, the database his engineers already use and love |
| 33 | + |
| 34 | + |
| 35 | +<div class="hide-admonition-title-container"> |
| 36 | + |
| 37 | +!!! tip |
| 38 | + |
| 39 | +<p class="center"> |
| 40 | + "Why add yet another database to your stack if you don't have to? Being able to co-locate your data – to query across the same metadata stack – is a no brainer.” |
| 41 | +</p> |
| 42 | + |
| 43 | +<p><i>James Yu, Founder @Sudowrite</i></p> |
| 44 | + |
| 45 | +!!! |
| 46 | + |
| 47 | +</div> |
| 48 | + |
| 49 | +## Quick and easy implementation |
| 50 | + |
| 51 | +Time to prototype was key for the Sudowrite team when testing out RAG systems. They used the Javascript SDK to get a full proof of concept chatbot fully synced to document changes in three hours flat. Once they decided to use PostgresML, it just took a few function calls with the SDK to start syncing data with production. |
| 52 | + |
| 53 | +“It was pretty easy,” James said. “I also just like the visibility. As it's indexing I can just refresh my Postgres and I see the chunks, I can inspect it all. It’s immediate validation.” His team knows Postgres, so there was no need to get familiar with a niche vector database service like Pinecone or Qdrant. |
| 54 | + |
| 55 | +James added: “I tried Pinecone and it felt very opaque - it’s a weird API and the data felt weirdly structured. I’m not going to pay exorbitant fees for a proprietary database where I’m not even sure how they’re performing the queries. I had to go through their UI, whereas for PostgresML I could visually see it in the same way as all my other data.” |
| 56 | + |
| 57 | +And since PostgresML has ML/AI functionality built-in, they didn’t need to create complex data pipelines to connect to embedding services, data pre-processors, or other ML/AI microservices. The Sudowrite team performs embedding generation and retrieval using SQL queries, right inside their PostgresML database. |
| 58 | + |
| 59 | +Additionally the Sudowrite team had access to an on-call PostgresML engineer and a private slack channel with same-day responses to ensure implementation was as smooth and fast as possible. |
| 60 | + |
| 61 | +"The support from the PostgresML team has been top-notch," James adds. "They're always quick to respond when we have questions, and they understand our need for flexibility.” |
| 62 | + |
| 63 | +## The results: In-database AI is a win for devs and users |
| 64 | + |
| 65 | +With PostgresML in place, Sudowrite's new AI chatbot feature is already making waves: |
| 66 | + |
| 67 | +- Sudowrite's RAG system makes more than 1 million calls per hour |
| 68 | +- The engineering team is loving the streamlined operations |
| 69 | +- A growing percentage of daily active users are chatting it up with the AI editor |
| 70 | + |
| 71 | +Performance and scalability were initial concerns for Sudowrite, given their large document base. James recalls his pleasant surprise: **"I thought, 'wow it's really fast, it's indexing all these things.' I was skeptical at first because we had a lot of documents, but it indexed quickly and it's really performant."** |
| 72 | + |
| 73 | +<div class="hide-admonition-title-container"> |
| 74 | + |
| 75 | +!!! tip |
| 76 | + |
| 77 | +<p class="center"> |
| 78 | +“The quality – especially the RAG piece – has been great. In terms of scaling and everything, it’s been great.” |
| 79 | +</p> |
| 80 | + |
| 81 | +!!! |
| 82 | + |
| 83 | +</div> |
| 84 | + |
| 85 | +Additionally, PostgresML's integration has been seamless for Sudowrite's development team, allowing engineers to focus on enhancing the user experience rather than wrestling with complex infrastructure. “I even have a contractor, and we handed it off to him pretty easily…And for him to be able to get up to speed was relatively painless,” James added. |
| 86 | + |
| 87 | +This efficiency has given Sudowrite confidence in their ability to scale the chatbot feature to meet growing demand – and the Sudowrite team sees tremendous potential for further adoption: "People want more chat. We have plans to make it more up front and center in the app." |
| 88 | + |
| 89 | +## What's next for Sudowrite? |
| 90 | + |
| 91 | +James and his team are just getting started. They're cooking up plans to: |
| 92 | + |
| 93 | +- Make the chatbot even more visible in the app |
| 94 | +- Allow authors to import their entire novel and interact with it via RAG |
| 95 | +- Create automated knowledge graphs from author’s stories |
| 96 | + |
| 97 | + |
| 98 | +<div class="hide-admonition-title-container"> |
| 99 | + |
| 100 | +!!! tip |
| 101 | + |
| 102 | +<p class="center"> |
| 103 | +“PostgresML has given us a solid foundation for our product. Their RAG extends the capabilities of our LLMs. It’s an essential ingredient for us to create tools that help writers create even more amazing stories." |
| 104 | +</p> |
| 105 | + |
| 106 | +!!! |
| 107 | + |
| 108 | +</div> |
| 109 | + |
| 110 | +## The bottom line |
| 111 | + |
| 112 | +By choosing PostgresML, Sudowrite found a powerful, flexible solution that: |
| 113 | + |
| 114 | +- Integrates seamlessly with their existing systems |
| 115 | +- Scales effortlessly without the need for complex infra management |
| 116 | +- Provides the transparency and flexibility to customize and expand their offering |
| 117 | + |
| 118 | +James sums it up perfectly: "For me, PostgresML just makes a lot of sense.” |
0 commit comments