File size: 973 Bytes
0aef757
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import torch
import pandas as pd
import streamlit as st
from transformers import AutoModelForCausalLM, AutoTokenizer
from langchain.llms import HuggingFacePipeline
from huggingface_hub import login
from pydantic import BaseModel, model_validator
from transformers import AutoConfig  # Importar para configurar el modelo

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

# NOTA: No se necesita rope_scaling para Mistral, por lo que esa configuración se omite
# Puedes investigar si el modelo Mistral usa algún tipo de escalado, pero en general no debería ser necesario en este caso.

# Nombre del modelo Mistral
model_name = "mistralai/Mistral-7B-Instruct"  # Cambia a un modelo Mistral específico si es necesario

# Cargar el modelo y el tokenizer de Mistral
config = AutoConfig.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, config=config)
tokenizer = AutoToken