Yunho Cho's picture
2 26

Yunho Cho

yhjc2692
Β·

AI & ML interests

inference optimization, world models, learning methods in robotics contexts

Recent Activity

liked a dataset 4 days ago
chengzu/topviewrs
liked a model 5 days ago
meta-llama/Llama-3.2-1B
liked a Space 17 days ago
mteb/leaderboard
View all activity

Organizations

SightWise's profile picture

yhjc2692's activity

reacted to andrewrreed's post with ❀️ 2 months ago
view post
Post
πŸš€ It's now easier than ever to switch from OpenAI to open LLMs

Hugging Face's TGI now supports an OpenAI compatible Chat Completion API

This means you can transition code that uses OpenAI client libraries (or frameworks like LangChain 🦜 and LlamaIndex πŸ¦™) to run open models by changing just two lines of code πŸ€—

⭐ Here's how:
from openai import OpenAI

# initialize the client but point it to TGI
client = OpenAI(
    base_url="<ENDPOINT_URL>" + "/v1/",  # replace with your endpoint url
    api_key="<HF_API_TOKEN>",  # replace with your token
)
chat_completion = client.chat.completions.create(
    model="tgi",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Why is open-source software important?"},
    ],
    stream=True,
    max_tokens=500
)

# iterate and print stream
for message in chat_completion:
    print(message.choices[0].delta.content, end="")


πŸ”— Blog post ➑ https://huggingface.co/blog/tgi-messages-api
πŸ”— TGI docs ➑ https://huggingface.co/docs/text-generation-inference/en/messages_api
Β·