File size: 2,090 Bytes
251623f
cf47d83
69e3a41
3d477e1
69e3a41
85ec4d4
 
 
 
251623f
c51c637
251623f
 
 
a77f2b3
 
 
70ed6f0
 
 
a3bc7ec
904cf6c
 
a3bc7ec
 
 
 
 
 
 
 
 
 
 
 
904cf6c
a3bc7ec
 
904cf6c
 
251623f
70ed6f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a3bc7ec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from transformers import AutoModelForCausalLM, AutoTokenizer
import streamlit as st
from huggingface_hub import login
import pandas as pd

# Token Secret of Hugging Face
huggingface_token = st.secrets["HUGGINGFACEHUB_API_TOKEN"]
login(huggingface_token)

# Cargar el modelo y el tokenizer
model_name = "meta-llama/Llama-3.2-1B-Instruct"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

# Asignar el eos_token como pad_token
tokenizer.pad_token = tokenizer.eos_token

# Upload CSV file
uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])

# Leer el archivo CSV si se ha subido
if uploaded_file is not None:
    df = pd.read_csv(uploaded_file)
    st.write(df.head())  # Mostrar las primeras filas del dataframe

    # Verificar si la columna 'job_title' está en el dataframe
    if 'job_title' in df.columns:
        job_titles = df['job_title'].tolist()
    else:
        st.error("La columna 'job_title' no se encuentra en el archivo CSV.")
        job_titles = []  # Asignar una lista vacía si la columna no existe

else:
    st.warning("Por favor, sube un archivo CSV.")
    job_titles = []  # Asignar una lista vacía si no se ha subido un archivo

# Definir la consulta
query = "aspiring human resources specialist"
st.write("Query:", query)

# Texto de entrada para la generación
input_text = (
    f"You are an AI assistant. You have a list of job titles and a search query.\n"
    f"Your task is to rank these job titles by their semantic similarity to the given query. "
    f"Please provide the ranking from most relevant to least relevant. "
    f"Do not calculate cosine similarity; instead, focus on understanding the semantic relevance of each job title to the query.\n"
    f"\n"
    f"Format your response like this:\n"
    f"1. [Most Relevant Job Title]\n"
    f"2. [Second Most Relevant Job Title]\n"
    f"...\n"
    f"N. [Least Relevant Job Title]\n"
    f"\n"
    f"Query: \"{query}\"\n"
    f"Job Titles: {job_titles}\n"
)

st.write("Texto de entrada para la generación:", input_text)