rasyosef/rag-with-phi-2-and-langchain

Retrieval Augmented Generation demo using Microsoft's phi-2 LLM and langchain

19

stars

7

commits

Python

primary language

Feb 12, 2024

updated

huggingface.co/spaces/rasyosef/RAG-with-Phi-2-and-LangChain
faiss
langchain
llm
nlp
question-answering
rag
retrieval-augmented-generation
sentence-transformers
transformers

README


title: RAG With Phi 2 And LangChain emoji: 👀 colorFrom: blue colorTo: blue sdk: gradio sdk_version: 4.14.0 app_file: app.py pinned: false

Retrieval Augmented Generation with Phi-2: Question Answering

If you don't have one, there is a txt file already loaded, the new Oppenheimer movie's entire wikipedia page. The movie came out very recently in July, 2023, so the Phi-2 model is not aware of it.

The context size of the Phi-2 model is 2048 tokens, so even this medium size wikipedia page (11.5k tokens) does not fit in the context window. Retrieval Augmented Generation (RAG) enables us to retrieve just the few small chunks of the document that are relevant to the our query and inject it into our prompt.

The model is then able to answer questions by incorporating knowledge from the newly provided document. RAG can be used with thousands of documents, but this demo is limited to just one txt file.

This demo was built using the Hugging Face transformers library, langchain, and gradio.

Demo

The demo has been depolyed to the following HuggingFace space.

https://huggingface.co/spaces/rasyosef/RAG-with-Phi-2-and-LangChain

Contributors

rasyosef

7 commits

rasyosef/rag-with-phi-2-and-langchain

Retrieval Augmented Generation demo using Microsoft's phi-2 LLM and langchain

19

stars

7

commits

Python

primary language

Feb 12, 2024

updated

huggingface.co/spaces/rasyosef/RAG-with-Phi-2-and-LangChain
faiss
langchain
llm
nlp
question-answering
rag
retrieval-augmented-generation
sentence-transformers
transformers

README


title: RAG With Phi 2 And LangChain emoji: 👀 colorFrom: blue colorTo: blue sdk: gradio sdk_version: 4.14.0 app_file: app.py pinned: false

Retrieval Augmented Generation with Phi-2: Question Answering

If you don't have one, there is a txt file already loaded, the new Oppenheimer movie's entire wikipedia page. The movie came out very recently in July, 2023, so the Phi-2 model is not aware of it.

The context size of the Phi-2 model is 2048 tokens, so even this medium size wikipedia page (11.5k tokens) does not fit in the context window. Retrieval Augmented Generation (RAG) enables us to retrieve just the few small chunks of the document that are relevant to the our query and inject it into our prompt.

The model is then able to answer questions by incorporating knowledge from the newly provided document. RAG can be used with thousands of documents, but this demo is limited to just one txt file.

This demo was built using the Hugging Face transformers library, langchain, and gradio.

Demo

The demo has been depolyed to the following HuggingFace space.

https://huggingface.co/spaces/rasyosef/RAG-with-Phi-2-and-LangChain

Contributors

rasyosef

7 commits

Languages

Python

100.0%