Downloads · 30 days
9
7% of all-time downloads
KalbeDigitalLab/alpara-7b-peft
alpara-7b-peft is a text generation model from KalbeDigitalLab. Use it when you need the model to write or continue text. It is set up for peft.
AlpaRA 7B, a model for medical dialogue understanding. Fine-tuned using the Alpaca configuration on a curated 5,000-instruction dataset capturing nuances in patient-doctor conversations. Use Parameter Efficient Fine T…
Downloads · 30 days
9
7% of all-time downloads
All-time downloads
131
Public
Repo size
16.8 MB
Likes
0
Public
Click a slice to open those files.
.safetensors16.8 MB · 100%
From the Hugging Face model README
AlpaRA 7B, a model for medical dialogue understanding. Fine-tuned using the Alpaca configuration on a curated 5,000-instruction dataset capturing nuances in patient-doctor conversations. Use Parameter Efficient Fine Tuning (PEFT) and Low Rank Adaptation (LoRA), make this model efficient on consumer-grade GPUs.
from peft import PeftModel
from transformers import LlamaTokenizer, LlamaForCausalLM, GenerationConfig
tokenizer = LlamaTokenizer.from_pretrained("yahma/llama-7b-hf")
model = LlamaForCausalLM.from_pretrained(
"yahma/llama-7b-hf",
load_in_8bit=True,
device_map="auto"
)
model = PeftModel.from_pretrained(model, "KalbeDigitalLab/alpara-7b-peft")
Feel free to change the instruction
PROMPT = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
"how to cure flu?"
### Response:"""
inputs = tokenizer(
PROMPT,
return_tensors="pt"
)
input_ids = inputs["input_ids"].cuda()
print("Generating...")
generation_output = model.generate(
input_ids=input_ids,
return_dict_in_generate=True,
output_scores=True,
max_new_tokens=512,
)
for s in generation_output.sequences:
result = tokenizer.decode(s).split("### Response:")[1]
print(result)