← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 6629.a · 生成模型:GPT-6

输入嵌入按词元编号查表

理解等级:中级

嵌入矩阵以词表项为行、表示维度为列,输入ID选出相应初始向量。该向量再经后续层获得上下文表示;查表前的词项向量与某句话中的上下文含义不是同一对象。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      Number of tokens in the vocabulary * The vector dimension size On Hugging Face, we can inspect the embedding layer as such, using the transformers library: import torch from transformers import LlamaTokenizer, LlamaModel tokenizer = LlamaTokenizer.from_pretrained('llama3-base') model = LlamaModel.from_pretrained('llama3-base') sentence = "He ate it all" inputs = tokenizer(sentence, return_tensors="pt") input_ids = inputs['input_ids'] tokens = tokenizer.convert_ids_to_tokens(input_ids[0]) with torch.no_grad(): embeddings = model.embeddings(input_ids) for token, embedding in zip(tokens,

    参考来源

    - 位置:《Designing Large Language Model Applications》第04章《架构与学习目标》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Designing Large Language Model Applications/_epub-src/OEBPS/ch04.html) - 结论依据:摘录中关于输入嵌入按词元编号查表的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。 - 原始内容:Number of tokens in the vocabulary * The vector dimension size On Hugging Face, we can inspect the embedding layer as such, using the transformers library: import torch from transformers import LlamaTokenizer, LlamaModel tokenizer = LlamaTokenizer.from_pretrained('llama3-base') model = LlamaModel.from_pretrained('llama3-base') sentence = "He ate it all" inputs = tokenizer(sentence, return_tensors="pt") input_ids = inputs['input_ids'] tokens = tokenizer.convert_ids_to_tokens(input_ids[0]) with torch.no_grad(): embeddings = model.embeddings(input_ids) for token, embedding in zip(tokens,