Views
No views yet
1!pip install -q --upgrade bitsandbytes transformers accelerate
2
3from transformers import pipeline
4
5pipe = pipeline("text-generation", model="alanjoshua2005/alan-mistral-finetuned")
6
7user_input = input("Enter your medical question or prompt: ")
8
9prompt = (
10 f"""Imagine you are a helpful medical chatbot. Respond based on the user input below:
11
12<s>[INST] {user_input} [/INST]
13
14Please provide your answer in **structured Markdown format**. Follow these rules:
15- Complete the answer fully; do not stop mid-sentence
16- Use emojis to highlight key points
17- Use horizontal lines (---) to separate sections
18- Use bullet points and numbered lists where appropriate
19- Use tables if necessary to organize information clearly
20- Explain medical terms in simple words
21- Do NOT include any links, URLs, or image references
22- Make the response easy-to-read and informative
23"""
24)
25
26result = pipe(
27 prompt,
28 max_new_tokens=512,
29 do_sample=True,
30 temperature=0.7,
31 top_p=0.9,
32 repetition_penalty=1.1
33)
34
35generated_text = result[0]["generated_text"]
36response = generated_text.replace(prompt, "").strip()
37
38print(response)ruslanmv/ai-medical-chatbot dataset using LoRA adapters on the Mistral 7B instruct model (4-bit). It is designed to provide accurate, easy-to-understand medical information in English.