Instructions to use Imran1/Med-R1-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Adapters
How to use Imran1/Med-R1-v1 with Adapters:
from adapters import AutoAdapterModel model = AutoAdapterModel.from_pretrained("undefined") model.load_adapter("Imran1/Med-R1-v1", set_active=True) - Notebooks
- Google Colab
- Kaggle
| library_name: adapter-transformers | |
| license: mit | |
| datasets: | |
| - FreedomIntelligence/medical-o1-reasoning-SFT | |
| language: | |
| - en | |
| # Model Card: Imran1/Med-R1-v1 | |
| ## Model Details | |
| - **Name**: Imran1/Med-R1-v1 | |
| - **Size**: 1B parameters | |
| - **Dataset**: `FreedomIntelligence/medical-o1-reasoning-SFT` | |
| - **Max Sequence Length**: 2048 tokens | |
| - **Quantization**: Supports 4-bit inference | |
| ## Description | |
| Imran1/Med-R1-v1 is a fine-tuned language model for medical reasoning, trained on structured medical datasets to provide contextually relevant and accurate responses for healthcare-related queries. | |
| ## Intended Use | |
| - **Use Cases**: Medical Q&A, reasoning for diagnoses, and treatment suggestions | |
| - **Users**: Healthcare professionals, researchers, and developers | |
| ## Example | |
| ```python | |
| from unsloth import FastLanguageModel | |
| from transformers import TextStreamer | |
| model_name = "Imran1/Med-R1-v1" | |
| max_seq_length = 2048 | |
| model, tokenizer = FastLanguageModel.from_pretrained( | |
| model_name=model_name, | |
| max_seq_length=max_seq_length, | |
| dtype=None, | |
| load_in_4bit=True, | |
| ) | |
| FastLanguageModel.for_inference(model) # Enable native 2x faster inference | |
| prompt = "i have pain in my kidney, what should i need to do?" | |
| messages = [ | |
| {"role": "system", "content": "You are AI medical assistant."}, | |
| {"role": "user", "content": prompt} | |
| ] | |
| text = tokenizer.apply_chat_template( | |
| messages, | |
| tokenize=False, | |
| add_generation_prompt=True | |
| ) | |
| inputs = tokenizer([text], return_tensors="pt").to(model.device) | |
| text_streamer = TextStreamer(tokenizer) | |
| generated_ids = model.generate( | |
| **inputs, | |
| streamer=text_streamer, | |
| max_new_tokens=2000 | |
| ) | |
| generated_ids = [ | |
| output_ids[len(input_ids):] for input_ids, output_ids in zip(inputs.input_ids, generated_ids) | |
| ] | |
| response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0] | |
| ``` | |
| ## output | |
| ``` | |
| <|begin▁of▁sentence|>You are AI medical assistant.<|User|>i have pain in my kidney, what should i need to do?<|Assistant|><|thinking|> Okay, let's think about this. When we have pain in the kidney, it's definitely something to take seriously. The kidneys are the main filters for blood, so there's definitely a risk of kidney issues. | |
| First, I should consider what the pain might mean. Could it be a urinary tract infection? That's a big possibility, but it could also be something like a kidney stones or a urinary tract blockage. And what about the rest of the body? Could there be a urinary tract infection or some kind of renal or urinary blockage? | |
| Now, I should think about what to do next. If it's a urinary tract infection, I'd want to go for an emergency treatment. This could mean antibiotics or maybe even surgery if it's severe. But if it's not severe, maybe a simple follow-up with a urinalysis could help. | |
| If it's not a kidney blockage, but there's pain, it might mean a urinary tract issue, like a kidney stones. In this case, I'd need to go for a urinalysis to see what's going on. | |
| Also, I should think about other potential issues. Like, could it be something like a renal vein or glomerulonephritis? Those would have different treatment plans. | |
| Hmm, let's not forget about the possibility of something like a kidney transplant. If that's the case, it's important to make sure the patient is healthy and there's no other risk to consider. | |
| So, in the end, the best next step is to check for what's causing the pain. If it's something like a kidney stone, a urinalysis is the way to go. But if it's a urinary tract infection, I'd need to get it treated fast. | |
| Alright, let's wrap it up. If it's a urinary tract infection, I need to act quickly. If it's a kidney stone, I'll need to do a urinalysis. And just in case, a kidney transplant is something to think about, but only if it seems like the best option given the situation. <|thinking_end|> | |
| <|Final|> When you experience pain in your kidney, it's important to approach the situation with a clear mind and consider the possible causes of the pain. Here's a structured approach to what you should do next: | |
| 1. **Assess the Pain Type**: Determine if the pain is likely due to a urinary tract infection (UTI), a kidney stone, or some other condition. This will guide the treatment approach. | |
| 2. **If Urethral Infection**: | |
| - If the pain is severe and worsens with exertion, it's likely a urinary tract infection. In this case, you should: | |
| - **Conduct a Urinalysis**: This will help identify any stones, infections, or other kidney issues. | |
| - **Immediate Treatment**: Depending on the severity, you may need antibiotics, surgery, or more invasive treatment like a kidney transplant if the infection is severe and advanced. | |
| 3. **If Kidney Stones**: | |
| - If pain is noticeable but not severe, it might indicate a kidney stone. In this situation, a urinalysis is recommended to assess the stone's size and shape. | |
| 4. **Other Considerations**: | |
| - **Renal Vein**: If the pain is in the urinary tract and there's no clear diagnosis of a kidney stone or infection, consider a renal vein. This may involve a lumbar puncture to check for blood flow and assess the condition. | |
| 5. **Other Potential Conditions**: | |
| - **Renal Transplant**: If you suspect renal vein involvement, a renal transplant could be considered, but only if there's no other risk or evidence of another renal issue. | |
| By following this structured approach, you can manage the pain effectively and take appropriate steps to address the underlying cause. <|Final_end|><|end▁of▁sentence|> | |
| ``` | |
| ## Limitations | |
| - **Not a substitute for medical advice**: This model provides general reasoning and suggestions but should not replace professional medical consultation. | |
| - **Dataset Bias**: The model’s outputs are influenced by the `FreedomIntelligence/medical-o1-reasoning-SFT` dataset and may reflect its limitations. | |
| - **Sensitive Use**: Ensure appropriate use in non-critical scenarios and always verify with certified professionals. | |
| ## Deployment | |
| The model supports efficient deployment with 4-bit quantization for inference. It is optimized for use in applications requiring medical reasoning and is compatible with Hugging Face and `unsloth` frameworks. | |
| ## Citation | |
| If you use this model, please cite: | |
| ```bibtex | |
| @model{imran1_med_r1_v1, | |
| title={Imran1/Med-R1-v1: A Medical Reasoning Language Model}, | |
| author={Imran1}, | |
| year={2025}, | |
| url={https://huggingface.co/Imran1/Med-R1-v1} | |
| } |