myngsoooo/CorningAI-DocQA
Viewer • Updated • 3.92k • 23
How to use nayohan/corningQA-llama2-13b-chat with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="nayohan/corningQA-llama2-13b-chat")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("nayohan/corningQA-llama2-13b-chat")
model = AutoModelForCausalLM.from_pretrained("nayohan/corningQA-llama2-13b-chat")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use nayohan/corningQA-llama2-13b-chat with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "nayohan/corningQA-llama2-13b-chat"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "nayohan/corningQA-llama2-13b-chat",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/nayohan/corningQA-llama2-13b-chat
How to use nayohan/corningQA-llama2-13b-chat with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "nayohan/corningQA-llama2-13b-chat" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "nayohan/corningQA-llama2-13b-chat",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "nayohan/corningQA-llama2-13b-chat" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "nayohan/corningQA-llama2-13b-chat",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use nayohan/corningQA-llama2-13b-chat with Docker Model Runner:
docker model run hf.co/nayohan/corningQA-llama2-13b-chat
This is a corning domain-specific model that has been trained to support multi-turn conversations in chemistry-related domains.
Use the following Python code to load the model:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("nayohan/corningQA-llama2-13b-chat")
model = AutoModelForCausalLM.from_pretrained(
"nayohan/corningQA-llama2-13b-chat",
device_map="auto",
torch_dtype=torch.float16,
)
To generate text, use the following Python code:
# SYSTEM PROMPT
context="A New CCn Inverter Circuit For AMLCD Panels Results In Significantly Higher Efficiency And Brightness Mehmet K. Nalbant Linfinity Microelectronics 11861 Western Ave., Garden Grove, CA 92641 Tel: (714) 898-8121 Fax: (714) 893-2570 Abstract - The paper will discuss a new CCFL inverter that is based on a new control technique named the Current Synchronous Zero Voltage Switching (CS-ZVS) topology. This topology enables the design of very eficient dimmable CCFL inverter"
diaogues= "Speaker 1: What is the name of the new control technique used in the CCFL inverter?\nSpeaker 2: The new control technique is called Current Synchronous Zero Voltage Switching (CS-ZVS) topology.\nSpeaker 1: Can you tell me more about the CS-ZVS topology?\nSpeaker 2: Sure! The CS-ZVS topology is a new control technique that allows for the design of highly efficient and dimmable CCFL inverters.\nSpeaker 1: That sounds impressive. How does it achieve higher efficiency and brightness?\nSpeaker 2: Well, the CS-ZVS topology synchronizes the switching of the inverter with the current flow, resulting in lower losses and improved performance.\nSpeaker 1: I see. So, is this new CCFL inverter already available in the market?\nSpeaker 2: Yes, it is. It was developed by Linfinity Microelectronics and is currently being used in AMLCD panels to improve their efficiency and brightness.\nSpeaker 1: That's amazing. I'm sure this new inverter will be very popular in the market.\nSpeaker 2: ###"
text = f"""
You will be shown dialogues between Speaker 1 and Speaker 2. Please read and understand given Dialogue Session,
then complete the task under the guidance of Task Introduction.\n
Context: {context}
Dialogue Session: {diaogues}
Task Introduction: After reading the Dialogue Session, please create an appropriate response in the parts marked ###.
Task Result:
"""
inputs = tokenizer(text, return_tensors="pt").to('cuda')
outputs = model.generate(**inputs, max_new_tokens=64)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
# USER INPUT:
{context}: A New CCn Inverter Circuit For AMLCD Panels Results In Significantly Higher Efficiency And Brightness Mehmet K. Nalbant Linfinity Microelectronics 11861 Western Ave., Garden Grove, CA 92641 Tel: (714) 898-8121 Fax: (714) 893-2570 Abstract - The paper will discuss a new CCFL inverter that is based on a new control technique named the Current Synchronous Zero Voltage Switching (CS-ZVS) topology. This topology enables the design of very eficient dimmable CCFL inverter
{diaogues}: Speaker 1: What is the name of the new control technique used in the CCFL inverter?\nSpeaker 2: The new control technique is called Current Synchronous Zero Voltage Switching (CS-ZVS) topology.\nSpeaker 1: Can you tell me more about the CS-ZVS topology?\nSpeaker 2: Sure! The CS-ZVS topology is a new control technique that allows for the design of highly efficient and dimmable CCFL inverters.\nSpeaker 1: That sounds impressive. How does it achieve higher efficiency and brightness?\nSpeaker 2: Well, the CS-ZVS topology synchronizes the switching of the inverter with the current flow, resulting in lower losses and improved performance.\nSpeaker 1: I see. So, is this new CCFL inverter already available in the market?\nSpeaker 2: Yes, it is. It was developed by Linfinity Microelectronics and is currently being used in AMLCD panels to improve their efficiency and brightness.\nSpeaker 1: That's amazing. I'm sure this new inverter will be very popular in the market.\nSpeaker 2: ###
# OUTPUT:
nayohan/corningQA-llama2-13b-chat: Thank you, we believe so too. The CS-ZVS topology has the potential to revolutionize the CCFL inverter market.
Context: A New CCn Inverter Circuit For AMLCD Panels Results In Significantly Higher Efficiency And Brightness Mehmet K. Nalbant Linfinity Microelectronics 11861 Western Ave., Garden Grove, CA 92641 Tel: (714) 898-8121 Fax: (714) 893-2570 Abstract - The paper will discuss a new CCFL inverter that is based on a new control technique named the Current Synchronous Zero Voltage Switching (CS-ZVS) topology. This topology enables the design of very eficient dimmable CCFL inverter
Dialogue Session: Speaker 1: What is the name of the new control technique used in the CCFL inverter?
Speaker 2: The new control technique is called Current Synchronous Zero Voltage Switching (CS-ZVS) topology.
Speaker 1: Can you tell me more about the CS-ZVS topology?
Speaker 2: Sure! The CS-ZVS topology is a new control technique that allows for the design of highly efficient and dimmable CCFL inverters.
Speaker 1: That sounds impressive. How does it achieve higher efficiency and brightness?
Speaker 2: Well, the CS-ZVS topology synchronizes the switching of the inverter with the current flow, resulting in lower losses and improved performance.
Speaker 1: I see. So, is this new CCFL inverter already available in the market?
Speaker 2: Yes, it is. It was developed by Linfinity Microelectronics and is currently being used in AMLCD panels to improve their efficiency and brightness.
Speaker 1: That's amazing. I'm sure this new inverter will be very popular in the market.
Speaker 2: ###
Task Introduction: After reading the Dialogue Session, please create an appropriate response in the parts marked ###.
Task Result:
Thank you, we believe so too. The CS-ZVS topology has the potential to revolutionize the CCFL inverter market.
@article{touvron2023llama,
title={Llama 2: Open foundation and fine-tuned chat models},
author={Touvron, Hugo and Martin, Louis and Stone, Kevin and Albert, Peter and Almahairi, Amjad and Babaei, Yasmine and Bashlykov, Nikolay and Batra, Soumya and Bhargava, Prajjwal and Bhosale, Shruti and others},
journal={arXiv preprint arXiv:2307.09288},
year={2023}
}
Our trainig code can be found here: Github: https://github.com/nayohan/2023-Corning-AI-Challenge