8000 feat: Pull models directly from huggingface by abetlen · Pull Request #1206 · abetlen/llama-cpp-python · GitHub
[go: up one dir, main page]

Skip to content

feat: Pull models directly from huggingface #1206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 21, 2024
Merged

feat: Pull models directly from huggingface #1206

merged 3 commits into from
Feb 21, 2024

Conversation

abetlen
Copy link
Owner
@abetlen abetlen commented Feb 21, 2024

Adds the ability to pull models directly from huggingface hub via a from_pretrained method on the Llama class. You'll need to pip install huggingface-hub to use this feature.

Usage

import llama_cpp

llama = llama_cpp.Llama.from_pretrained(
    repo_id="Qwen/Qwen1.5-0.5B-Chat-GGUF",
    filename="*q8_0.gguf",
    verbose=False
)

response = llama.create_chat_completion(
    messages=[
        {
            "role": "user",
            "content": "What is the capital of France?"
        }
    ],
    response_format={
        "type": "json_object",
        "schema": {
            "type": "object",
            "properties": {
                "country": {"type": "string"},
                "capital": {"type": "string"}
            },
            "required": ["country", "capital"],
        }
    },
    stream=True
)

for chunk in response:
    delta = chunk["choices"][0]["delta"]
    if "content" not in delta:
        continue
    print(delta["content"], end="", flush=True)

print()

Closes #1145

@abetlen abetlen merged commit 0f8aa4a into main Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically pull models from Huggingface
1 participant
0