robinhad commited on
Commit
c08a038
·
verified ·
1 Parent(s): fbaf277

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -11,6 +11,7 @@ import torch.nn.functional as F
11
  from transformers import AutoModelForCausalLM, AutoProcessor, AutoTokenizer, TextIteratorStreamer, AutoModel, AutoModelForSequenceClassification
12
  from kernels import get_kernel
13
  from typing import Any, Optional, Dict
 
14
 
15
 
16
  # Login to HF to get access to the model weights
@@ -78,11 +79,20 @@ def bot(user_message: str, history: list[dict[str, Any]]):
78
 
79
  res = ""
80
  history = history + [{"role": "user", "content": user_message}]
 
81
  for model_choice in MODEL_OPTIONS:
82
  model, tokenizer = load_model(model_choice) # returns embedding model
83
  score = compute_score(user_message, model, tokenizer)["score"]
 
84
  res += f"{model_choice}: {score}\n"
85
 
 
 
 
 
 
 
 
86
  history.append({"role": "assistant", "content": res.strip()})
87
  return "", history
88
 
 
11
  from transformers import AutoModelForCausalLM, AutoProcessor, AutoTokenizer, TextIteratorStreamer, AutoModel, AutoModelForSequenceClassification
12
  from kernels import get_kernel
13
  from typing import Any, Optional, Dict
14
+ import numpy as np
15
 
16
 
17
  # Login to HF to get access to the model weights
 
79
 
80
  res = ""
81
  history = history + [{"role": "user", "content": user_message}]
82
+ scores = {}
83
  for model_choice in MODEL_OPTIONS:
84
  model, tokenizer = load_model(model_choice) # returns embedding model
85
  score = compute_score(user_message, model, tokenizer)["score"]
86
+ scores["model_choice"] = score
87
  res += f"{model_choice}: {score}\n"
88
 
89
+
90
+
91
+ formula_score = np.median([scores["lapa-llm/fineweb-nemotron-edu-score"], scores["lapa-llm/fineweb-mixtral-edu-score"], scores["lapa-llm/fasttext-quality-score"],]) \
92
+ * item["lapa-llm/alignment-score-model"] * scores["lapa-llm/manipulative-score-model"] * scores["lapa-llm/gec-score-model"]
93
+
94
+ res += f"Formula (combined) score: {formula_score}\n"
95
+
96
  history.append({"role": "assistant", "content": res.strip()})
97
  return "", history
98