saifeddinemk commited on
Commit
71a0d39
1 Parent(s): 91207a8
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -10,10 +10,12 @@ app = FastAPI()
10
  base_model_name = "akjindal53244/Llama-3.1-Storm-8B"
11
  peft_model_id = "LlamaFactoryAI/cv-job-description-matching"
12
 
13
- base_model = AutoModelForCausalLM.from_pretrained(base_model_name)
 
14
  tokenizer = AutoTokenizer.from_pretrained(base_model_name)
15
  config = PeftConfig.from_pretrained(peft_model_id)
16
- model = PeftModel.from_pretrained(base_model, peft_model_id)
 
17
 
18
  # Define request model
19
  class AnalysisRequest(BaseModel):
@@ -45,7 +47,7 @@ async def analyze(request: AnalysisRequest):
45
 
46
  # Tokenize and generate response
47
  inputs = tokenizer(input_text, return_tensors="pt")
48
- outputs = model.generate(**inputs, max_new_tokens=128)
49
  generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
50
 
51
  return {"analysis": generated_text}
 
10
  base_model_name = "akjindal53244/Llama-3.1-Storm-8B"
11
  peft_model_id = "LlamaFactoryAI/cv-job-description-matching"
12
 
13
+ base_model = AutoModelForCausalLM.from_pretrained(base_model_name, torch_dtype=torch.float16)
14
+ model = PeftModel.from_pretrained(base_model, peft_model_id, torch_dtype=torch.float16)
15
  tokenizer = AutoTokenizer.from_pretrained(base_model_name)
16
  config = PeftConfig.from_pretrained(peft_model_id)
17
+
18
+
19
 
20
  # Define request model
21
  class AnalysisRequest(BaseModel):
 
47
 
48
  # Tokenize and generate response
49
  inputs = tokenizer(input_text, return_tensors="pt")
50
+ outputs = model.generate(**inputs, max_new_tokens=64)
51
  generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
52
 
53
  return {"analysis": generated_text}