如何在HuggingFaceLLM中设置llama3中的eos_token_id?

问题描述 投票:0回答:1

我想设置我的eos_token_id和pad_token_id。我用谷歌搜索了很多,大多数人建议使用例如tokenizer.pad_token_id(就像从这里https://huggingface.co/meta-llama/Meta-Llama-3-8B/discussions/36)。但问题是我的代码没有启动标记器。

我查看了Llama3官方页面https://llama.meta.com/docs/model-cards-and-prompt-formats/meta-llama-3/,它没有显示代码。

虽然我的代码是这样的:

import os
from llama_index.core import StorageContext, load_index_from_storage
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.llms.huggingface import HuggingFaceLLM
import torch

# Define the LLM
llm = HuggingFaceLLM(
    context_window=4096,
    max_new_tokens=256,  # Reduce max new tokens for faster inference
    generate_kwargs={
        "temperature": 0.1,
        "do_sample": True,
        "pad_token_id": 128001 , 
        "eos_token_id": 128001   
    },
    tokenizer_name="meta-llama/Meta-Llama-3-8B-Instruct",
    model_name="meta-llama/Meta-Llama-3-8B-Instruct",
    device_map="auto",
    model_kwargs={"torch_dtype": torch.float16}
)

所以我的问题是,pad 和 eos 代币 id 的正确设置应该是什么?我确定不是 128001。有人可以帮忙吗?

large-language-model huggingface huggingface-tokenizers llama-index llama3
1个回答
0
投票

对于为我工作的 eos_token:

"eos_token_id": [128001, 128009]

在底部找到:https://github.com/vllm-project/vllm/issues/4180

对于 pad_token,我想你可以像这里建议的那样忽略它: https://github.com/meta-llama/llama3/issues/42

© www.soinside.com 2019 - 2024. All rights reserved.