embedchain/notebooks/hugging_face_hub.ipynb
!pip install embedchain[huggingface_hub,opensource]
You can find your HUGGINGFACE_ACCESS_TOKEN key on your Hugging Face Hub dashboard
import os
from embedchain import App
os.environ["HUGGINGFACE_ACCESS_TOKEN"] = "hf_xxx"
app = App.from_config(config={
"llm": {
"provider": "huggingface",
"config": {
"model": "google/flan-t5-xxl",
"temperature": 0.5,
"max_tokens": 1000,
"top_p": 0.8,
"stream": False
}
},
"embedder": {
"provider": "huggingface",
"config": {
"model": "sentence-transformers/all-mpnet-base-v2"
}
}
})
app.add("https://www.forbes.com/profile/elon-musk")
while(True):
question = input("Enter question: ")
if question in ['q', 'exit', 'quit']:
break
answer = app.query(question)
print(answer)