Spaces:
Sleeping
Sleeping
Download model_loader.py from Alimubariz124/chat-with-data: direct link, hf CLI and curl.
- Browser
- Download file 496 Bytes
-
https://huggingface.co/spaces/Alimubariz124/chat-with-data/resolve/main/model_loader.py
- Command line
-
hf download hf://spaces/Alimubariz124/chat-with-data/model_loader.py
-
curl -L -o model_loader.py https://huggingface.co/spaces/Alimubariz124/chat-with-data/resolve/main/model_loader.py
496 Bytes
| from sentence_transformers import SentenceTransformer | |
| from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline | |
| def load_embedding_model(): | |
| return SentenceTransformer("all-MiniLM-L6-v2") | |
| def load_llm(): | |
| model_name = "google/flan-t5-base" | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForSeq2SeqLM.from_pretrained(model_name) | |
| pipe = pipeline("text2text-generation", model=model, tokenizer=tokenizer, max_new_tokens=200) | |
| return pipe | |