Skip to content
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

how to use textgrad with huggingface pipeline llm #121

Open
Sahilgul opened this issue Sep 12, 2024 · 0 comments
Open

how to use textgrad with huggingface pipeline llm #121

Sahilgul opened this issue Sep 12, 2024 · 0 comments

Comments

@Sahilgul
Copy link

Sahilgul commented Sep 12, 2024

# Colab Env to Run llama3.1

import torch
from langchain_huggingface import HuggingFacePipeline
from transformers import AutoModelForCausalLM, AutoTokenizer,pipeline
model_id = "meta-llama/Meta-Llama-3.1-8B"

tokenizer = AutoTokenizer.from_pretrained(model_id,skip_special_tokens=True)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map='balanced')


pipe = pipeline(
                "text-generation",
                model=model,
                tokenizer=tokenizer,
                max_new_tokens=256,
                temperature=0,
                do_sample=False,
                return_full_text=False
            )
from langchain_huggingface import HuggingFacePipeline
llm = HuggingFacePipeline(pipeline=pipe)
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

No branches or pull requests

1 participant