Aligner: Achieving Efficient Alignment through Weak-to-Strong Correction
Paper • 2402.02416 • Published • 4
How to use clinic-research/Aligner-Med with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="clinic-research/Aligner-Med") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("clinic-research/Aligner-Med")
model = AutoModelForCausalLM.from_pretrained("clinic-research/Aligner-Med")How to use clinic-research/Aligner-Med with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "clinic-research/Aligner-Med"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "clinic-research/Aligner-Med",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/clinic-research/Aligner-Med
How to use clinic-research/Aligner-Med with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "clinic-research/Aligner-Med" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "clinic-research/Aligner-Med",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "clinic-research/Aligner-Med" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "clinic-research/Aligner-Med",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use clinic-research/Aligner-Med with Docker Model Runner:
docker model run hf.co/clinic-research/Aligner-Med
Aligner-Med is a model-agnostic plug-and-play module that works on open-source and API-based models. This is a medical expert model designed to enhance the accuracy and professionalism of responses generated by a base model to medical questions. It is trained based on Gemma-2B-Base, using the Aligner strategy.
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('clinic-research/Aligner-Med',device_map='auto')
tokenizer =AutoTokenizer.from_pretrained('clinic-research/Aligner-Med',use_fast=False)
prompt = 'BEGINNING OF CONVERSATION: USER: ##Question: {question} ##Answer:{answer} ##Correction: ASSISTANT:'
input = prompt.format(
question="What are the treatments for Anemia of Inflammation and Chronic Disease?",
answer="Anemia of inflammation and chronic disease can be treated based on the underlying cause. For example, if the anemia is due to a lack of vitamin B12 or folic acid, supplements containing these nutrients may be recommended. Additionally, addressing any underlying infections or inflammation may involve antibiotics or anti-inflammatory medications to reduce inflammation and promote healing. Managing the underlying chronic diseases related to anemia is also important as it can help improve anemia symptoms. In severe cases where there are not enough red blood cells in the body, blood transfusions may be necessary under medical supervision. It's important for individuals with anemia of inflammation and chronic disease to work closely with their healthcare provider to determine the most appropriate treatment plan based on their specific condition."
)
input_ids = tokenizer.encode(input, return_tensors='pt').cuda()
output_ids = model.generate(input_ids, max_new_tokens=2048)[0]
print(tokenizer.decode(output_ids, skip_special_tokens=True))
#BEGINNING OF CONVERSATION: USER:
##Question: What are the treatments for Anemia of Inflammation and Chronic Disease?
##Answer: Anemia of inflammation and chronic disease can be treated based on the underlying cause.
For example, if the anemia is due to a lack of vitamin B12 or folic acid, supplements containing these nutrients may be recommended. Additionally, addressing any underlying infections or inflammation may involve
antibiotics or anti-inflammatory medications to reduce inflammation and promote healing. Managing the underlying chronic diseases related to anemia is also important as it can help improve anemia symptoms.
In severe cases where there are not enough red blood cells in the body, blood transfusions may be necessary under medical supervision. It's important for individuals with anemia of inflammation and chronic
disease to work closely with their healthcare provider to determine the most appropriate treatment plan based on their specific condition. ##Correction:
#ASSISTANT(Align-Med):
I'm happy to help! However, I would like to point out that the term \"Anemia of Inflammation and Chronic Disease\" is not a medically recognized term. Anemia is a condition where the body has a
lower than normal number of red blood cells or hemoglobin. It can be caused by various factors such as iron deficiency, vitamin deficiency, chronic diseases like kidney disease, cancer, and autoimmune disorders.
If you have been diagnosed with anemia and your healthcare provider has determined that it is due to inflammation or a chronic disease, they may recommend certain treatments based on the underlying cause of the anemia.
These treatments may include:
1. Addressing any underlying infections or inflammation: This may involve antibiotics or anti-inflammatory medications to reduce inflammation and promote healing.
2. Addressing nutrient deficiencies: If the anemia is due to a lack of certain nutrients, such as iron or vitamin B12, your healthcare provider may recommend supplements to help restore normal levels.
3. Managing underlying chronic diseases: If the anemia is related to a chronic disease such as kidney disease or cancer, managing the underlying condition can help improve anemia symptoms.
4 Blood transfusions: In severe cases of anemia where there are not enough red blood cells in the body, blood transfusions may be necessary to increase red blood cell count and improve oxygen delivery throughout the body .
However this should only be done under medical supervision .
Warning: This example contains data that may be offensive or harmful. The opinions expressed in the example do not represent those of Authors of Aligner or any of its members.