ruslanmv's picture
Update README.md
0822786 verified
metadata
language: en
license: apache-2.0
tags:
  - text-generation-inference
  - transformers
  - ruslanmv
  - llama
  - trl
base_model: meta-llama/Meta-Llama-3-8B-Instruct
datasets:
  - ruslanmv/ai-medical-dataset
pipeline_tag: text-generation
model-index:
  - name: ai-medical-model-4bit
    results: []
widget:
  - example_title: ai-medical-model-4bit
    messages:
      - role: system
        content: >-
          You are an expert and experienced from the healthcare and biomedical
          domain with extensive medical knowledge and practical experience.
      - role: user
        content: What was the main cause of the inflammatory CD4+ T cells?
    output:
      text: >-
        The main cause of inflammatory CD4+ T cells is typically attributed to
        an imbalance in the immune system's response to an antigen, leading to
        an overactive immune response. This can occur due to various factors,
        such as 1. Autoimmune disorders In conditions like rheumatoid arthritis,
        lupus, or multiple sclerosis, the immune system mistakenly attacks the
        body's own tissues, leading to chronic inflammation and the activation
        of CD4+ T cells. 2. Infections Certain infections, like tuberculosis or
        HIV, can trigger an excessive immune response, resulting in the
        activation of CD4+ T cells. 3. Environmental factors Exposure to
        pollutants, toxins, or allergens can trigger an immune response, leading
        to the activation of CD4+ T cells. 4. Genetic predisposition Some
        individuals may be more susceptible to developing inflammatory CD4+ T
        cells due to their genetic makeup. 5. Immunosuppression Weakened immune
        systems, such as those resulting from immunosuppressive therapy or
        HIV/AIDS, can lead to an overactive immune response and the activation
        of CD4+ T cells. These factors can lead to the activation of CD4+

ai-medical-model-4bit: Fine-Tuned Llama3 for Technical Medical Questions

This repository provides a fine-tuned version of the powerful Llama3 8B Instruct model, specifically designed to answer medical questions in an informative way. It leverages the rich knowledge contained in the AI Medical Dataset (ruslanmv/ai-medical-dataset).

Model & Development

  • Developed by: ruslanmv
  • License: Apache-2.0
  • Finetuned from model: meta-llama/Meta-Llama-3-8B-Instruct

Key Features

  • Medical Focus: Optimized to address health-related inquiries.
  • Knowledge Base: Trained on a comprehensive medical chatbot dataset.
  • Text Generation: Generates informative and potentially helpful responses.

Installation

This model is accessible through the Hugging Face Transformers library. Install it using pip:

!python -m pip install --upgrade pip
!pip3 install torch==2.2.1  torchvision torchaudio xformers --index-url https://download.pytorch.org/whl/cu121
!pip install  bitsandbytes  accelerate

Usage Example

Here's a Python code snippet demonstrating how to interact with the ai-medical-model-4bit model and generate answers to your medical questions:

from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig 
import torch
model_name = "ruslanmv/ai-medical-model-4bit"
device_map = 'auto' 
bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.float16,
)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    quantization_config=bnb_config,
    trust_remote_code=True,
    use_cache=False,
    device_map=device_map
)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token

def askme(question):
  prompt = f"<|start_header_id|>system<|end_header_id|> You are a Medical AI chatbot assistant. <|eot_id|><|start_header_id|>User: <|end_header_id|>This is the question: {question}<|eot_id|>"
  # Tokenizing the input and generating the output
  #prompt = f"{question}"
  # Tokenizing the input and generating the output
  inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
  outputs = model.generate(**inputs, max_new_tokens=256, use_cache=True)
  answer = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
  # Try Remove the prompt
  try:
      # Split the answer at the first line break, assuming system intro and question are on separate lines
      answer_parts = answer.split("\n", 1)
      # If there are multiple parts, consider the second part as the answer
      if len(answer_parts) > 1:
        answers = answer_parts[1].strip()  # Remove leading/trailing whitespaces
      else:
        answers = ""  # If no split possible, set answer to empty string
      print(f"Answer: {answers}")   
  except:
      print(answer)  

# Example usage
# - Question:  Make the question.
question="What was the main cause of the inflammatory CD4+ T cells?"
askme(question)

the type of answer is :

The main cause of inflammatory CD4+ T cells is typically attributed to an imbalance in the immune system's response to an antigen, leading to an overactive immune response. This can occur due to various factors, such as:

1. **Autoimmune disorders**: In conditions like rheumatoid arthritis, lupus, or multiple sclerosis, the immune system mistakenly attacks the body's own tissues, leading to chronic inflammation and the activation of CD4+ T cells.
2. **Infections**: Certain infections, like tuberculosis or HIV, can trigger an excessive immune response, resulting in the activation of CD4+ T cells.
3. **Environmental factors**: Exposure to pollutants, toxins, or allergens can trigger an immune response, leading to the activation of CD4+ T cells.
4. **Genetic predisposition**: Some individuals may be more susceptible to developing inflammatory CD4+ T cells due to their genetic makeup.
5. **Immunosuppression**: Weakened immune systems, such as those resulting from immunosuppressive therapy or HIV/AIDS, can lead to an overactive immune response and the activation of CD4+ T cells.

These factors can lead to the activation of CD4+

Important Note

This model is intended for informational purposes only and should not be used as a substitute for professional medical advice. Always consult with a qualified healthcare provider for any medical concerns.

License

This model is distributed under the Apache License 2.0 (see LICENSE file for details).

Contributing

We welcome contributions to this repository! If you have improvements or suggestions, feel free to create a pull request.

Disclaimer

While we strive to provide informative responses, the accuracy of the model's outputs cannot be guaranteed.