addcorpbc commited on
Commit ·
739ccde
1
Parent(s): 0698313
Fixed dataset loading with Hugging Face dataset name
Browse files1234564 unmodified lines111213141516172 unmodified lines2021222324252627282930313233343536373813 unmodified lines52535455565758from transformers import AutoTokenizer, AutoModelForCausalLM, Trainer, TrainingArgumentsfrom datasets import load_datasetimport os# Authenticate using a token from environment variableshf_token = os.getenv("HFTOKEN")4 unmodified linescache_dir = "./model_cache"os.makedirs(cache_dir, exist_ok=True)# Load pre-trained LLaMA model and tokenizertokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf", cache_dir=cache_dir, use_auth_token=hf_token)model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf",2 unmodified linesuse_auth_token=hf_token # Pass the token for authenticated model loading)# Load the dataset from Hugging Facedataset = load_dataset("addcorpbc/personality-assesment", # Dataset namedata_files={"train": ["https://huggingface.co/datasets/addcorpbc/personality-assesment/resolve/main/Card%20Sorting.txt","https://huggingface.co/datasets/addcorpbc/personality-assesment/resolve/main/Counselor%20Personality.txt","https://huggingface.co/datasets/addcorpbc/personality-assesment/resolve/main/MBPTI.txt","https://huggingface.co/datasets/addcorpbc/personality-assesment/resolve/main/Riasec.txt","https://huggingface.co/datasets/addcorpbc/personality-assesment/resolve/main/Strong%20INterest%20Index.txt"]})# Fine-tuning configurationstraining_args = TrainingArguments(13 unmodified linesmodel=model, # the pre-trained modelargs=training_args, # training argumentstrain_dataset=dataset["train"], # training dataseteval_dataset=None # No validation split if you choose not to use it)# Fine-tune the model12345674 unmodified lines121314151617182 unmodified lines212223242526272813 unmodified lines42434445464748from transformers import AutoTokenizer, AutoModelForCausalLM, Trainer, TrainingArgumentsimport gradio as grimport osfrom datasets import load_dataset# Authenticate using a token from environment variableshf_token = os.getenv("HFTOKEN")4 unmodified linescache_dir = "./model_cache"os.makedirs(cache_dir, exist_ok=True)# Load pre-trained model and tokenizertokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf", cache_dir=cache_dir, use_auth_token=hf_token)model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf",2 unmodified linesuse_auth_token=hf_token # Pass the token for authenticated model loading)# Load the dataset directly from Hugging Facedataset = load_dataset("addcorpbc/personality-assesment")# Fine-tuning configurationstraining_args = TrainingArguments(13 unmodified linesmodel=model, # the pre-trained modelargs=training_args, # training argumentstrain_dataset=dataset["train"], # training dataseteval_dataset=dataset.get("validation", None), # optional: validation dataset if available)# Fine-tune the model
app.py+6-16