🚀 COCOMモデル
COCOMは、長いコンテキストを少数のコンテキスト埋め込みに圧縮することで、質問応答の生成時間を高速化する、効果的なコンテキスト圧縮手法です。
🚀 クイックスタート
COCOMは、長いコンテキストを少数のコンテキスト埋め込みに圧縮することで、質問応答の生成時間を大幅に短縮する効果的なコンテキスト圧縮手法です。

✨ 主な機能
Retrieval-Augmented Generation (RAG) は、外部コンテキストを入力に追加することで、大規模言語モデル (LLM) の知識の限界を克服することができます。しかし、RAGの主な欠点は、入力が長くなるほどデコード時間が大幅に増加することです。この課題に対して、我々はCOCOMという効果的なコンテキスト圧縮手法を提案します。この手法は、長いコンテキストを少数のコンテキスト埋め込みに圧縮することで、生成時間を高速化します。我々の手法では、異なる圧縮率を選択することができ、デコード時間と回答品質をトレードオフすることができます。以前の手法と比較して、COCOMは複数のコンテキストをより効果的に処理することができ、長い入力に対するデコード時間を大幅に短縮します。我々の手法は、既存の効率的なコンテキスト圧縮手法と比較して、最大5.69倍の高速化を実現し、より高い性能を達成します。
📦 インストール
このセクションではインストールに関する具体的な内容がありませんので、スキップします。
💻 使用例
基本的な使用法
from transformers import AutoModel
model = AutoModel.from_pretrained('naver/cocom-v1-4-mistral-7b', trust_remote_code=True)
model = model.to('cuda')
contexts = [[
'Rosalind Bailey. Rosalind Bailey Rosalind Bailey (born 1946) is a British actress, known for her portrayal of Sarah Headley ("née" Lytton) in the 1970s and 1980s BBC television drama “When the Boat Comes In". Bailey has appeared in numerous British television drama series, including "Byker Grove", “Distant Shores" and "Burn Up". Her stage work includes playing Miss Mary Shepherd in Alan Bennett’s play "The Lady in the Van”.',
'Malcolm Terris. Malcolm Terris Malcolm Terris (born 11 January 1941 in Sunderland, County Durham) is a British actor. He had a lengthy career in a large number of television programmes. Possibly his best-known role was in "When the Boat Comes In", a popular 1970s series, where he played the part of Matt Headley. His film career includes appearances in "The First Great Train Robbery" (1978), "McVicar" (1980), "The Plague Dogs" (1982, voice only), "Slayground" (1983), “The Bounty" (1984) as Thomas Huggan, ship’s surgeon, "Mata Hari" (1985), "Revolution" (1985), “Scandal" (1989), and “Chaplin” (1992). His TV appearances include: One episode of',
'When the Boat Comes In. When the Boat Comes In When the Boat Comes In is a British television period drama produced by the BBC between 1976 and 1981. The series stars James Bolam as Jack Ford, a First World War veteran who returns to his poverty-stricken (fictional) town of Gallowshield in the North East of England. The series dramatises the political struggles of the 1920s and 1930s and explores the impact of national and international politics upon Ford and the people around him. Section:Production. The majority of episodes were written by creator James Mitchell, but in Series 1 north-eastern',
'Susie Youssef. Youssef began her comedy career as a writer for "The Ronnie Johns Half Hour" in 2006, and made her acting debut in the short film "Clicked" in the role of Lina in 2011. In 2014, she played Jane in the short film "Kevin Needs to Make New Friends: Because Everyone Hates Him for Some Reason" and then turned to television where she appeared in "The Chaser’s Media Circus". In 2014, Youssef played the lead role of Sarah in the Hayloft Project’s stage play "The Boat People" which won the Best On Stage award at the FBi SMAC Awards',
'Madelaine Newton. Madelaine Newton Madelaine Newton is a British actress best known for her portrayal of Dolly in 1970s BBC television drama "When the Boat Comes In". She is married to actor Kevin Whately, known for his role as Robert "Robbie" Lewis in both "Inspector Morse” and its spin-off "Lewis". They have two children. She starred alongside her husband in the “Inspector Morse" episode "Masonic Mysteries" as Beryl Newsome - the love-interest of Morse - whom Morse was wrongly suspected of murdering. She played Whately’s on-screen wife in the 1988 Look and Read children’s serial, Geordie Racer. She also made'
]]
questions = ['who played sarah hedley in when the boat comes in?']
answers = model.generate_from_text(contexts=contexts, questions=questions, max_new_tokens=128)
print(answers)
高度な使用法
このセクションで高度な使用法に関する具体的な内容がありませんので、スキップします。
📚 ドキュメント
バッチ処理では、モデルは以下の入力を受け取ります。
questions
(list
):質問を含むリスト
contexts
(list of lists
):各質問に対するコンテキストのリスト。質問全体でコンテキストの数は固定されています。モデルは 5
つのコンテキストで微調整されています(推論時も同じコンテキスト数を使用する必要があります)。
モデルは質問をコンテキスト埋め込みに圧縮し、提供されたコンテキスト埋め込みに基づいて質問に回答します。
🔧 技術詳細
このセクションで技術的な詳細に関する具体的な内容がありませんので、スキップします。
📄 ライセンス
このセクションでライセンスに関する具体的な内容がありませんので、スキップします。
参考文献
論文: https://arxiv.org/pdf/2407.09252
@misc{rau2024contextembeddingsefficientanswer,
title={Context Embeddings for Efficient Answer Generation in RAG},
author={David Rau and Shuai Wang and Hervé Déjean and Stéphane Clinchant},
year={2024},
eprint={2407.09252},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2407.09252},
}