如果这不是提出这个问题的最佳地点,请引导我找到最准确的地点。
我计划使用 Huggingface 摘要模型之一 ( https://huggingface.co/models?pipeline_tag=summarization ) 来总结我的讲座视频转录。
到目前为止,我已经测试了facebook/bart-large-cnn和sshleifer/distilbart-cnn-12-6,但它们最多只支持 1,024 个令牌作为输入。
所以,这是我的问题:
是否有支持更长输入(例如 10,000 字文章)的摘要模型?
对于给定的输入长度,最佳输出长度是多少?假设对于 1,000 个单词的输入,最佳(最小)输出长度(摘要文本的最小长度)是多少?
哪种模型可能适用于编程相关文章?
nlp summarization mlmodel huggingface-transformers huggingface
我正在尝试运行 Huggingface StableDiffusion 生成文本到图像模型的 Colab 示例:
\nhttps://huggingface.co/CompVis/stable-diffusion \n https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/stable_diffusion.ipynb#scrollTo=xSKWBKFPArKS
\n然而,它在模型加载时卡住了:
\n\n使用该模型需要在 Huggingface 注册和一个令牌 - 我有一个,我还得到了一个令牌,该令牌在上一个单元格中已被接受:
\n\n错误发生后,我还执行了建议的命令:\n!git config --global credential.helper store
虽然我不认为这是必须要做的事情。
\n我发现了这个:\n https://huggingface.co/docs/hub/repositories-getting-started \n(虽然我不会推送,但只会下载。)
\n\n\n为了能够将您的代码推送到集线器,您\xe2\x80\x99需要\以某种方式进行身份验证。最简单的方法是安装\nhuggingface_hub CLI 并运行登录命令:
\n
python -m pip install huggingface_hub\nhuggingface-cli login\nRun Code Online (Sandbox Code Playgroud)\n我安装并运行它:
\n!python -m pip install huggingface_hub\n!huggingface-cli login\nRun Code Online (Sandbox Code Playgroud)\n\n我使用我的令牌(读取)登录 - 登录成功。
\n但是,在尝试下载模型时它仍然返回相同的错误。
\n如何“确保我已登录huggingface-cli login”?
谢谢!
\n给定huggingface上的变压器模型,如何找到最大输入序列长度?
例如,这里我想截断到模型的 max_length:tokenizer(examples["text"], padding="max_length", truncation=True)How do I find the value of "max_length"?
我需要知道,因为我正在尝试解决此错误“要求填充到 max_length 但未提供最大长度,并且模型没有预定义的最大长度。默认为无填充。”
pytorch huggingface-transformers huggingface-tokenizers huggingface
colab:https://colab.research.google.com/drive/1poFdFYmkR_rDM5U5Z2WWjTepMQ8h vzNc?usp=sharing
HF falcon 教程有以下行:
tokenizer.pad_token = tokenizer.eos_token
Run Code Online (Sandbox Code Playgroud)
我觉得很奇怪。pad 和 eos 是相同的,但为什么首先要在它们之间做出区分呢?
请注意,这样做 pad = eos. 这意味着在微调期间,模型永远不会被训练为输出 eos(最有可能),因为 eos 被视为填充令牌并且不会反向传播:
I just observed that when I set tokenizer.pad_token = tokenizer.eos_token during training, the model won't stop generating during inference, since it was trained to not output the eos token (per discussions above).
Run Code Online (Sandbox Code Playgroud)
我看到了这个(这里https://github.com/huggingface/transformers/issues/22794):
tokenizer.add_special_tokens({'pad_token': '[PAD]'})
Run Code Online (Sandbox Code Playgroud)
但这假设模型有 pad_token。我认为必须进行额外的检查,确保它确实具有 pad_token 的嵌入,以便不存在运行时错误(〜从嵌入“表”/矩阵提取矩阵中的类型错误)。
但如果这样做,可能需要注意初始化新令牌,以便它主导生成: https: //nlp.stanford.edu/~johnhew/vocab-expansion.html
代码:
tokenizer.pad_token = tokenizer.eos_token
Run Code Online (Sandbox Code Playgroud)
该死的,这仍然不起作用:
UserWarning: You …Run Code Online (Sandbox Code Playgroud) machine-learning pytorch huggingface-transformers huggingface-tokenizers huggingface
我正在尝试加载(人民语音)数据集,但它太大了,有没有办法只下载其中的一部分?
from datasets import load_dataset
from datasets import load_dataset
train = load_dataset("MLCommons/peoples_speech", "clean",split="train[:10%]")
test = load_dataset("MLCommons/peoples_speech", "clean",split="test[:10%]")
Run Code Online (Sandbox Code Playgroud)
使用 ("train [: 10%]") 没有帮助,它仍在尝试下载整个数据集......
假设我有以下模型(来自此脚本):
\nfrom transformers import AutoTokenizer, GPT2LMHeadModel, AutoConfig\n\nconfig = AutoConfig.from_pretrained(\n "gpt2",\n vocab_size=len(tokenizer),\n n_ctx=context_length,\n bos_token_id=tokenizer.bos_token_id,\n eos_token_id=tokenizer.eos_token_id,\n)\nmodel = GPT2LMHeadModel(config)\nRun Code Online (Sandbox Code Playgroud)\n我目前正在为 Trainer 使用以下训练参数:
\nfrom transformers import Trainer, TrainingArguments\n\nargs = TrainingArguments(\n output_dir="codeparrot-ds",\n per_device_train_batch_size=32,\n per_device_eval_batch_size=32,\n evaluation_strategy="steps",\n eval_steps=5_000,\n logging_steps=5_000,\n gradient_accumulation_steps=8,\n num_train_epochs=1,\n weight_decay=0.1,\n warmup_steps=1_000,\n lr_scheduler_type="cosine",\n learning_rate=5e-4,\n save_steps=5_000,\n fp16=True,\n push_to_hub=True,\n)\n\ntrainer = Trainer(\n model=model,\n tokenizer=tokenizer,\n args=args,\n data_collator=data_collator,\n train_dataset=tokenized_datasets["train"],\n eval_dataset=tokenized_datasets["valid"],\n)\ntrainer.train()\nRun Code Online (Sandbox Code Playgroud)\n我如何对此进行调整,以便训练器将使用多个 GPU(例如 8 个)?
\n我发现了这个问题,但他们没有使用 Trainer,只是使用 PyTorchDataParallel
model = torch.nn.DataParallel(model, device_ids=[0,1])\nRun Code Online (Sandbox Code Playgroud)\n关于使用多个 GPU 进行训练的Huggingface文档对我来说并不是很清楚,并且没有使用 Trainer 的示例。相反,我在这里发现他们使用 …
machine-learning pytorch huggingface-transformers huggingface
from langchain import PromptTemplate, HuggingFaceHub, LLMChain
import os
os.environ['HUGGINGFACEHUB_API_TOKEN'] = 'token'
# initialize HF LLM
flan_t5 = HuggingFaceHub(
repo_id="google/flan-t5-xl",
model_kwargs={"temperature": 1e-10}
)
multi_template = """Answer the following questions one at a time.
Questions:
{questions}
Answers:
"""
long_prompt = PromptTemplate(
template=multi_template,
input_variables=["questions"]
)
llm_chain = LLMChain(
prompt=long_prompt,
llm=flan_t5
)
qs_str = (
"Which NFL team won the Super Bowl in the 2010 season?\n" +
"If I am 6 ft 4 inches, how tall am I in centimeters?\n" +
"Who was the …Run Code Online (Sandbox Code Playgroud) 我想在我的数据集和 GCP VM 实例上微调 Starcoder ( https://huggingface.co/bigcode/starcoder )。
文档中称,为了训练模型,他们使用了 512 个 Tesla A100 GPU,花了 24 天。
我还在 HuggingFace 的文件部分中看到了模型(.bin)文件(https://huggingface.co/bigcode/starcoder/tree/main)
模型总大小约为64GB
根据所有这些信息,
deep-learning language-model pytorch huggingface large-language-model
我对生成式人工智能非常陌生。我有 64GB RAM 和 20GB GPU。我使用了 Huggingface 的一些开源模型,并使用 Python 简单地用开箱即用的模型提示并显示结果。我使用将模型下载到本地save_pretrained,然后尝试从本地加载模型。有用。但每次运行 python 文件都需要 10 多分钟才能显示结果。
有一个步骤Loading checkpoint shards每次需要6-7分钟。我做错了什么吗?为什么它每次都必须加载一些东西,即使模型是从本地引用的。
我尝试使用local_files_only=True, cache_dir=cache_dir, low_cpu_mem_usage=True, max_shard_size="200MB",没有解决时间问题。
如何在用户可用的情况下直接提示已保存的模型而不需要太多延迟。任何帮助将不胜感激
h2o huggingface-transformers huggingface-tokenizers huggingface llama
我对两个 Huggingface 管道TextGeneration和Text2TextGeneration之间的技术差异感到困惑。
在 TextGeneration 中指出:
使用任何 ModelWithLMHead 的语言生成管道。该管道预测指定文本提示后面的单词。
但不是有语言模型可以做到这一点吗?“预测下一个单词”?那么这个管道与 Text2TextGeneration 有什么不同呢?Text2TextGeneration 不会预测下一个可能的单词吗?
我还尝试了使用“Text2TextGeneration”管道的一些模型,尽管 HuggingFace 发出警告“该模型不支持 text2text- Generation”,但它实际上有效并生成了一些输出。
如果有人可以解释技术差异,我们将不胜感激。