JaphetHernandez commited on
Commit
34c6fb2
·
verified ·
1 Parent(s): bded51b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -13
app.py CHANGED
@@ -1,13 +1,31 @@
1
  from transformers import AutoModelForCausalLM, AutoTokenizer
2
  import torch
 
3
 
4
- # Cargar el modelo y tokenizer de LLaMA 2
 
 
 
 
5
  model_name = "meta-llama/Llama-2-7b-hf" # O ajusta según el modelo que prefieras
6
- tokenizer = AutoTokenizer.from_pretrained(model_name)
7
- model = AutoModelForCausalLM.from_pretrained(model_name)
 
 
 
 
 
 
 
8
 
9
- # Crear prompt
10
- prompt = """
 
 
 
 
 
 
11
  You are an advanced AI assistant trained to process job titles and user queries. I will provide you with a list of job titles, and a user query. Your task is to:
12
 
13
  1. Calculate the cosine similarity score between the query and each job title.
@@ -15,14 +33,9 @@ You are an advanced AI assistant trained to process job titles and user queries.
15
  3. Return the top 5 job titles with their cosine similarity scores.
16
 
17
  Here is the list of job titles from the CSV:
18
- - Software Engineer
19
- - Data Scientist
20
- - Machine Learning Engineer
21
- - Business Analyst
22
- - Product Manager
23
- ...
24
-
25
- The user's query is: "Machine Learning Expert"
26
 
27
  Now, compute the similarity scores, rank the job titles, and return the top 5.
28
  """
 
1
  from transformers import AutoModelForCausalLM, AutoTokenizer
2
  import torch
3
+ import pandas as pd
4
 
5
+ # Tu token secreto de Hugging Face
6
+ huggingface_token = st.secrets["HUGGINGFACEHUB_API_TOKEN"]
7
+
8
+
9
+ # Cargar el modelo y tokenizer de LLaMA 2, usando el token secreto
10
  model_name = "meta-llama/Llama-2-7b-hf" # O ajusta según el modelo que prefieras
11
+ tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=huggingface_token)
12
+ model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=huggingface_token)
13
+
14
+ # Pedir al usuario que introduzca el path del archivo CSV
15
+ csv_file = input("Por favor introduce la ruta del archivo CSV: ")
16
+
17
+ # Cargar el CSV y extraer la columna 'job_titles'
18
+ df = pd.read_csv(csv_file)
19
+ job_titles = df['job_titles'].tolist()
20
 
21
+ # Crear la lista de job titles en formato de texto para el prompt
22
+ job_titles_text = "\n".join(f"- {title}" for title in job_titles)
23
+
24
+ # Query del usuario
25
+ user_query = input("Introduce tu query: ")
26
+
27
+ # Crear el prompt usando los job titles del CSV y la query del usuario
28
+ prompt = f"""
29
  You are an advanced AI assistant trained to process job titles and user queries. I will provide you with a list of job titles, and a user query. Your task is to:
30
 
31
  1. Calculate the cosine similarity score between the query and each job title.
 
33
  3. Return the top 5 job titles with their cosine similarity scores.
34
 
35
  Here is the list of job titles from the CSV:
36
+ {job_titles_text}
37
+
38
+ The user's query is: "{user_query}"
 
 
 
 
 
39
 
40
  Now, compute the similarity scores, rank the job titles, and return the top 5.
41
  """