Skip to content

Commit

Permalink
Revert "RAG-pipeline"
Browse files Browse the repository at this point in the history
This reverts commit cad4205.
  • Loading branch information
sonam-pankaj95 committed May 20, 2024
1 parent 8389de9 commit c899fba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 259 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
</p>

[![Downloads](https://static.pepy.tech/badge/embed-anything)](https://pepy.tech/project/embed-anything)
[![Multimodal Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1CowJrqZxDDYJzkclI-rbHaZHgL9C6K3p?usp=sharing)
[![RAG Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://drive.google.com/file/d/1GCSJ7kMwJWT86khVN9JrP_I-v0ipeWvP/view?usp=sharing)
[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1CowJrqZxDDYJzkclI-rbHaZHgL9C6K3p?usp=sharing)
[![license]( https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![license]( https://img.shields.io/badge/Package-PYPI-blue.svg)](https://pypi.org/project/embed-anything/)
[![license](https://img.shields.io/discord/1213966302046064711?style=flat&logo=discord&link=https%3A%2F%2Fdiscord.gg%2FHGxDZxNt9G)](https://discord.gg/juETVTMdZu)
Expand All @@ -33,7 +32,6 @@ We will soon post on how we use Candle to increase the performance and decrease

## Examples
1. Image Search: [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1CowJrqZxDDYJzkclI-rbHaZHgL9C6K3p?usp=sharing)
2. RAG with Pinecone: [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://drive.google.com/file/d/1GCSJ7kMwJWT86khVN9JrP_I-v0ipeWvP/view?usp=sharing)

[Watch the demo](https://youtu.be/HLXIuznnXcI)

Expand Down
223 changes: 0 additions & 223 deletions examples/RAG.ipynb

This file was deleted.

40 changes: 7 additions & 33 deletions retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,16 @@
pc = Pinecone(api_key="")
index = pc.Index("anything")

for i in range(len(data)):
index.upsert(
vectors=[{"id": str(i), "values": data[i].embedding, "metadata": {"text": data[i].text}}]
)
# for i in range(len(data)):
# index.upsert(
# vectors=[{"id": str(i), "values": data[i].embedding, "metadata": {"text": data[i].text}}]
# )



def retrieval(query):
query_embedding = embed_anything.embed_query(query, embeder="OpenAI")
context = index.query(vector=query_embedding[0].embedding, top_k=2)
indices = [int(context.matches[i]['id']) for i in range(len(context.matches))]
return indices
return index.query(vector=query_embedding[0].embedding, top_k=2)
index.fetch(["82", "81"])

indices = retrieval(["what is AI?"])

def get_text(indices):
return [index.fetch([str(e)])['vectors'][str(e)]['metadata']['text'] for e in indices]



content = query + " "
for i in range(min(len(indices), 3)):
content += get_text(indices)[i] + " "



client = OpenAI()



response = client.chat.completions.create(
model="gpt-3.5-turbo-0125",
response_format={ "type": "json_object" },
messages=[
{"role": "system", "content": "You are a helpful assistant designed to output JSON."},
{"role": "user", "content": content}
]
)
print(response.choices[0].message.content)
# print(retrieval(["what is AI?"]))

0 comments on commit c899fba

Please sign in to comment.