Views
No views yet
ollama run Elixpo/LlamaMedicine1# run before testing this
2# pip install unsloth bitsandbytes transformers
3
4
5from unsloth import FastLanguageModel
6from transformers import AutoTokenizer
7import torch
8
9# Load the quantized model from Hugging Face
10model_name = "Elixpo/llamaMED"
11model, _ = FastLanguageModel.from_pretrained(model_name)
12
13# Prepare the model for inference
14model = FastLanguageModel.for_inference(model)
15
16# Determine the device (GPU or CPU)
17device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
18
19# Move the model to the appropriate device
20model = model.to(device)
21
22# Load the tokenizer from Hugging Face
23tokenizer = AutoTokenizer.from_pretrained(model_name)
24
25# Test the model
26input_text = "What are the symptoms of diabetes?"
27inputs = tokenizer(input_text, return_tensors="pt")
28
29# Move the input tensors to the same device as the model
30inputs = {key: value.to(device) for key, value in inputs.items()}
31
32# Generate output using the model
33outputs = model.generate(inputs['input_ids'], max_length=100)
34
35# Decode the output
36print(tokenizer.decode(outputs[0], skip_special_tokens=True))
37lavita/ChatDoctor-HealthCareMagic-100k dataset from Hugging Face.Modelfile to adjust the assistant’s behavior.