Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -70,9 +70,11 @@ def run_deepseek(req1, req2, prompt_type):
|
|
| 70 |
|
| 71 |
def run_llama(req1, req2, prompt_type):
|
| 72 |
model_name = "meta-llama/Llama-3.1-8B-Instruct"
|
| 73 |
-
|
|
|
|
| 74 |
model = AutoModelForCausalLM.from_pretrained(
|
| 75 |
model_name,
|
|
|
|
| 76 |
dtype=torch.bfloat16,
|
| 77 |
device_map="auto"
|
| 78 |
)
|
|
@@ -81,8 +83,9 @@ def run_llama(req1, req2, prompt_type):
|
|
| 81 |
outputs = model.generate(inputs.input_ids, max_new_tokens=256)
|
| 82 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 83 |
|
|
|
|
| 84 |
def run_fanar(req1, req2, prompt_type):
|
| 85 |
-
client = OpenAI(base_url="https://api.fanar.qa/v1", api_key="
|
| 86 |
prompt = build_prompt(req1, req2, prompt_type)
|
| 87 |
response = client.chat.completions.create(
|
| 88 |
model="Fanar",
|
|
|
|
| 70 |
|
| 71 |
def run_llama(req1, req2, prompt_type):
|
| 72 |
model_name = "meta-llama/Llama-3.1-8B-Instruct"
|
| 73 |
+
hf_token = os.getenv("LLAMA_HF_TOKEN")
|
| 74 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, token=hf_token)
|
| 75 |
model = AutoModelForCausalLM.from_pretrained(
|
| 76 |
model_name,
|
| 77 |
+
token=hf_token,
|
| 78 |
dtype=torch.bfloat16,
|
| 79 |
device_map="auto"
|
| 80 |
)
|
|
|
|
| 83 |
outputs = model.generate(inputs.input_ids, max_new_tokens=256)
|
| 84 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 85 |
|
| 86 |
+
|
| 87 |
def run_fanar(req1, req2, prompt_type):
|
| 88 |
+
client = OpenAI(base_url="https://api.fanar.qa/v1", api_key=os.getenv("FANAR_API"))
|
| 89 |
prompt = build_prompt(req1, req2, prompt_type)
|
| 90 |
response = client.chat.completions.create(
|
| 91 |
model="Fanar",
|