I wrote the following code on my laptop to run a finetuned mistral-7b-bnb-4bit model that I finetuned using unsloth
import torch
from transformers import AutoModel, AutoTokenizer
# Load the model and tokenizer
model_path = '/Users/sarannathreddy/Downloads/content/fine_tune_blumistral'
model = AutoModel.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path)
def query_model(text):
inputs = tokenizer(text, return_tensors='pt')
with torch.no_grad():
outputs = model(**inputs)
return outputs
output = query_model("Create a table with event code from windows table")
print(output)
When executed, the expected behaviour of the code is to produce output that was similar to what it was finetuned on, which in its case was specific json structures that was to be used in the backend code in response to specific requests, but instead I ended up getting the following output
Some weights of MistralModel were not initialized from the model checkpoint at /Users/sarannathreddy/Downloads/content/fine_tune_blumistral and are newly initialized: ['embed_tokens.weight', 'layers.0.input_layernorm.weight', 'layers.0.mlp.down_proj.weight', ....... , 'layers.9.self_attn.q_proj.weight', 'layers.9.self_attn.v_proj.weight', 'norm.weight'] You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
It runs for some time after this warning pops up and just gives me a bunch of weights like follows
[[-2.0262e+00, 1.1631e+00, -1.2465e+00, ..., 1.6002e-01, 5.5240e-01, -1.1690e+00], [-6.4968e-01, -9.7237e-02, -1.3797e+00, ..., -1.4068e+00, 6.2171e-01, 8.0008e-01], [-7.2705e-01, -6.9598e-01, -2.3596e+00, ..., 7.7411e-01,...
Here is the structure of the model directory that I download after finetuning
.
└── fine_tune_blumistral
├── README.md
├── config.json
├── model.safetensors
├── special_tokens_map.json
├── tokenizer.json
├── tokenizer.model
└── tokenizer_config.json
I would like to be able to output from the model what it was trained on instead of its weights.
None of the solutions that i found online helped me solve my issue so if anyone has any insights it would be greatly appreciated!