[HN Gopher] Using GPT3, Supabase and Pinecone to automate a pers...
       ___________________________________________________________________
        
       Using GPT3, Supabase and Pinecone to automate a personalized
       marketing campaign
        
       Author : vimota
       Score  : 93 points
       Date   : 2023-02-25 18:22 UTC (4 hours ago)
        
 (HTM) web link (vimota.me)
 (TXT) w3m dump (vimota.me)
        
       | swyx wrote:
       | > And it pretty much worked! Using prompts to find matches is not
       | really ideal, but we want to use GPT's semantic understanding.
       | That's where Embeddings come in.
       | 
       | sounds like you ended up not using GPT3 in the end which is
       | probably wise.
       | 
       | i'm curious if you might see further savings using other cheaper
       | embeddings that are available on huggingface. but its probably
       | not material at this point.
       | 
       | did you also consider using pgvector instead of pinecone?
       | https://news.ycombinator.com/item?id=34684593 any painpoints with
       | pinecone you can recall?
        
         | vimota wrote:
         | I didn't use the GPT3 autocomplete API in the end (though I did
         | play around with it) but did use the embeddings API (which I
         | believe is still considered part of the "GPT3" model, but I
         | could be wrong!).
         | 
         | I totally could! I think each use case should dictate which
         | model you should use, in my case I was not super cost or
         | latency sensitive since it was a small dataset and I cared more
         | about accuracy. But I'm planning on using something like
         | https://huggingface.co/sentence-transformers/all-MiniLM-L6-v...
         | for my next project where latency and cost will matter more :)
         | 
         | I have a lot of thoughts around that last question! The article
         | came out way after I implemented this (August of last year) so
         | I didn't even think to do that, not sure if it was even
         | supported back then, but I'd probably reach for that if I was
         | re-doing the project to reduce the number of systems I needed.
         | I think the power of having the vector search done in the same
         | DB as the rest of the data is that sometimes you may want to
         | have structured filtering before the semantic/vector ranking
         | (ie. only select user N's items and rank by similarity to
         | <query>) which is trickier to do in Pinecone. They support
         | metadata filtering but it feels like an after thought. For the
         | project I'm working on now (https://pinched.io) , we'd like to
         | filter on certain parameters as well as rank by relevance, so
         | I'm going to explore combining structured querying with
         | semantic search (ie. pgvector or something similar on DuckDB if
         | it adds support for this).
        
         | devxpy wrote:
         | Creating the index on pinecone takes about a minute. Creating a
         | table on postgres should take a few milliseconds!
        
         | roseway4 wrote:
         | I've seen really good results using BERT and other open-source
         | models for matching symptoms / healthcare service names to
         | CPT/HCPCS code descriptions. Even for specialized domains, some
         | of the freely available models perform well for ANN search.
         | While BERT may not be viewed as state-of-the-art, versions of
         | it have relatively low memory requirements versus newer models
         | which is nice if you're self-hosting and/or care about
         | scalability.
        
           | joshgel wrote:
           | I'm curious what problems you've applied this to. Would love
           | to chat if you are open. (My email is in my profile)
        
       | pbourke wrote:
       | > My script read through each of the products we had responses
       | for, called OpenAI's embedding api and loaded it into Pinecone -
       | with a reference to the Supabase response entry.
       | 
       | OpenAI and the Pinecone database are not really needed for this
       | task. A simple SBERT encoding of the product texts, followed by
       | storing the vectors in a dense numpy array or faiss index would
       | be more than sufficient. Especially if one is operating in batch
       | mode, the locality and simplicity can't be beat and you can
       | easily scale to 100k-1M texts in your corpus on commodity
       | hardware/VPS (though NVME disk will see a nice performance gain
       | over regular SSD)
        
         | vimota wrote:
         | Yep that's true! I'd probably do something like that if I were
         | starting again, but the ease of calling a few APIs is pretty
         | nice. I feel like that alone will drive a lot of adoption of
         | some of these platforms even if it can just be done locally.
        
         | bilater wrote:
         | most HN comment ever
        
       | [deleted]
        
       | Hyption wrote:
       | I don't like the unscientific ad for his gf company.
       | 
       | 'which helped launch the movement of those opposed to endocrine
       | disruptors, was retracted and its author found to have committed
       | scientific misconduct'
        
       | pjakubowski wrote:
       | Awesome to see the integration between Klaviyo automation and
       | GPT-3 AI and using it to streamline your girlfriends processes.
       | Keep up the fantastic work!
        
       | mdorazio wrote:
       | Are you saving the match pairs somewhere? I imagine 1) there are
       | a finite number of them, 2) doing an exact lookup in a DB first
       | will be faster and easier than calling GPT3 and Pinecone every
       | time, and 3) eventually GPT3 APIs will get pricey enough to make
       | you think twice unless you're running your own instance on a
       | cluster.
        
       | jamesblonde wrote:
       | I have see a lot of people write about how important the
       | interaction between vector DBs and chat-GPT3 (and GPT3) is. I am
       | still not much wiser after this article. Is it that it makes it
       | easier to go from:
       | 
       | user query -> GPT3 response -> Lookup in VectorDB -> send
       | response based on closest embedding in VectorDB
       | 
       | ?
        
         | pablo24602 wrote:
         | All the embedding-enabled GPT-3 apps I've seen do the
         | following: User query -> Retrieve closest embedding's plaintext
         | counterpart -> feed plaintext as context to GPT-3 prompt.
        
           | jamesblonde wrote:
           | Is this a form of prompt engineering then?
           | 
           | Your vector DB has well formed prompts - users write random
           | stuff, map it to the closest well formed prompt?
        
             | [deleted]
        
             | roseway4 wrote:
             | In this context, it is for semantic matching similar to:
             | 
             | "My daily face cream is BrandX's low-sheen formulation" ->
             | "BrandX Matte Face Moisturizer"
        
         | vimota wrote:
         | To be clear, I didn't use the autocomplete GPT-3 API just the
         | embeddings one! Pinecone has some good docs on it:
         | https://docs.pinecone.io/docs/openai. Happy to answer any
         | questions :)
        
       ___________________________________________________________________
       (page generated 2023-02-25 23:00 UTC)