Spaces:
Runtime error
Runtime error
misteral
Browse files- selection.py +3 -3
selection.py
CHANGED
|
@@ -4,7 +4,7 @@ from sklearn.feature_extraction.text import TfidfVectorizer
|
|
| 4 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 5 |
from datasets import load_dataset
|
| 6 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 7 |
-
|
| 8 |
def find_most_relevant_context(contexts, question, max_features=10000):
|
| 9 |
# Vectorize contexts and question with limited features
|
| 10 |
tfidf_vectorizer = TfidfVectorizer(max_features=max_features)
|
|
@@ -35,8 +35,8 @@ instruction = most_relevant_context[:300] + " " + Question
|
|
| 35 |
|
| 36 |
# Load Mistral model and tokenizer
|
| 37 |
model_name = "mistralai/Mistral-7B-v0.1" # Replace with the appropriate Mistral model name if available
|
| 38 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 39 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 40 |
|
| 41 |
|
| 42 |
# Tokenize the input
|
|
|
|
| 4 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 5 |
from datasets import load_dataset
|
| 6 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 7 |
+
my_token = os.getenv('my_repo_token')
|
| 8 |
def find_most_relevant_context(contexts, question, max_features=10000):
|
| 9 |
# Vectorize contexts and question with limited features
|
| 10 |
tfidf_vectorizer = TfidfVectorizer(max_features=max_features)
|
|
|
|
| 35 |
|
| 36 |
# Load Mistral model and tokenizer
|
| 37 |
model_name = "mistralai/Mistral-7B-v0.1" # Replace with the appropriate Mistral model name if available
|
| 38 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name , token= my_token)
|
| 39 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, token= my_token)
|
| 40 |
|
| 41 |
|
| 42 |
# Tokenize the input
|