Downloads · 30 days
5
5% of all-time downloads
axel-datos/mistral_finetuned
mistral_finetuned is a machine learning model from axel-datos. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as apache-2.0.
Fine tuned mistral that takes queries of code as input to a formal specification of the code in docstring format.
Downloads · 30 days
5
5% of all-time downloads
All-time downloads
104
Public
Repo size
1.8 GB
Likes
0
Public
Click a slice to open those files.
.safetensors600 MB · 100%
From the Hugging Face model README
Fine tuned mistral that takes queries of code as input to a formal specification of the code in docstring format.
Developed by: Axel Fridman
Finetuned from model: https://huggingface.co/mistralai/Mistral-7B-v0.1
Use any device with CUDA. In google colab choose T4 for free GPU
Install dependencies
# You only need to run this once per machine
!pip install -q -U bitsandbytes
!pip install -q -U git+https://github.com/huggingface/transformers.git
!pip install -q -U git+https://github.com/huggingface/peft.git
!pip install -q -U git+https://github.com/huggingface/accelerate.git
!pip install -q -U datasets scipy ipywidgets matplotlib
!pip3 install torch torchvision
import torch
Load base model Mistral-7B before loading finetuned parameters
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
base_model_id = "mistralai/Mistral-7B-v0.1"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id, # Mistral, same as before
quantization_config=bnb_config, # Same quantization config as before
device_map="auto",
trust_remote_code=True,
)
eval_tokenizer = AutoTokenizer.from_pretrained(base_model_id, add_bos_token=True, trust_remote_code=True)
Download ft parameters from Hugging Face and create model combining with base model
from peft import PeftModel
ft_model = PeftModel.from_pretrained(base_model,"axel-datos/mistral_finetuned")
Tokenize the input and use model, adjust parameters as wished.
eval_prompt = "provide function that encrypts every element of a list and returns a new list of pairs (non encrypted element, encrypted element)"
model_input = eval_tokenizer(eval_prompt, return_tensors="pt").to("cuda")
ft_model.eval()
with torch.no_grad():
print(eval_tokenizer.decode(ft_model.generate(**model_input, max_new_tokens=200, repetition_penalty=1.15)[0], skip_special_tokens=True))
Inside repository there is a file called evaluationWithQueries.json