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

HF integration #291

Merged
merged 14 commits into from
Jul 17, 2024
Merged

HF integration #291

merged 14 commits into from
Jul 17, 2024

Conversation

sedrick-keh-tri
Copy link
Collaborator

@sedrick-keh-tri sedrick-keh-tri commented Jul 16, 2024

Download OpenLM with pip:
pip install git+https://github.com/mlfoundations/open_lm.git

Import OpenLM classes with
from open_lm.hf import *

Then the rest can be done with native HF code:

from open_lm.hf import *
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("apple/DCLM-Baseline-7B")
model = AutoModelForCausalLM.from_pretrained("apple/DCLM-Baseline-7B")

inputs = tokenizer(["Machine learning is"], return_tensors="pt")
gen_kwargs = {"max_new_tokens": 50, "top_p": 0.8, "temperature": 0.8, "do_sample": True, "repetition_penalty": 1.1}
output = model.generate(inputs['input_ids'], **gen_kwargs)
output = tokenizer.decode(output[0].tolist(), skip_special_tokens=True)
print(output)

@sedrick-keh-tri sedrick-keh-tri mentioned this pull request Jul 17, 2024
@Vaishaal Vaishaal merged commit c0f1319 into mlfoundations:main Jul 17, 2024
2 checks passed
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.

2 participants