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

Decoding Parameters #2

Open
LydiaKoerber opened this issue Mar 21, 2024 · 0 comments
Open

Decoding Parameters #2

LydiaKoerber opened this issue Mar 21, 2024 · 0 comments

Comments

@LydiaKoerber
Copy link

I am trying to use TimeLlama-7b-chat, loading it from HuggingFace.
I am using the following code to load the model:

model_name = "chrisyuan45/TimeLlama-7b-chat"
quantization_config = BitsAndBytesConfig.from_dict({
    'load_in_4bit': True,
    'bnb_4bit_compute_dtype': torch.float16,
    'bnb_4bit_quant_type': 'nf4',
    'bnb_4bit_use_double_quant':True})

model = LlamaForCausalLM.from_pretrained(
        model_name,
        return_dict=True,
        quantization_config = quantization_config,
        device_map="auto",
        low_cpu_mem_usage=True)
tokenizer = LlamaTokenizer.from_pretrained(model_name)

and the following for generation:

input_ids = tokenizer.encode(prompt, return_tensors="pt")
input_ids = input_ids.to('cuda')
ids = model.generate(input_ids,
                    max_length=200,
                    num_return_sequences=3,
                    no_repeat_ngram_size=2)
output = [tokenizer.decode(ids[i], skip_special_tokens=True) for i in range(len(ids))]

So far, the outputs are not very good, e.g. incomplete sentences or special characters. Could you please provide the decoding parameters that you used for your experiments? Thank you in advance!

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