模型简介
模型特点
模型能力
使用案例
🚀 多语言模型Kraken
Kraken多语言模型及架构是一个强大的语言处理工具,由多方合作打造,支持多种语言,能根据输入智能选择合适的模型生成文本,为不同语言场景提供灵活、准确的响应。
🚀 快速开始
加载和调用Kraken多语言模型
from transformers import AutoModelForCausalLM
device = "cuda:0" ## 若使用NVIDIA显卡,设置为 "cuda:0";若使用Mac,设置为 "mps"
# 加载模型和配置:
model = AutoModelForCausalLM.from_pretrained("./kraken_model", trust_remote_code=True)
调用不同语言专家模型示例
调用德语专家模型
messages = [
{'role': 'system', 'content': 'Du bist ein freundlicher und hilfreicher deutscher KI-Assistent'},
{'role': 'user', 'content': "Erzähle mir eine kurze Gute Nacht Geschichte in 2 Sätzen."}
]
tokenizer = model.tokenizer
input_text = tokenizer.apply_chat_template(messages, tokenize=False)
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda:0")
output_ids = model.generate(input_ids, max_length=150)
print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
调用英语专家模型
messages = [
{'role': 'system', 'content': '"You are a helpful AI Assistant'},
{'role': 'user', 'content': "Find the mass percentage of Ba in BaO"}
]
tokenizer = model.tokenizer
input_text = tokenizer.apply_chat_template(messages, tokenize=False)
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
output_ids = model.generate(input_ids, max_length=250)
print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
调用意大利语专家模型
messages = [
{'role': 'system', 'content': 'Sei un utile assistente AI.'},
{'role': 'user', 'content': 'Hai qualche idea su cosa potrei fare a Roma?'}
]
tokenizer = model.tokenizer
input_text = tokenizer.apply_chat_template(messages, tokenize=False)
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
output_ids = model.generate(input_ids ,temperature=0.6, do_sample=True, top_p=0.9,top_k=20, max_length=500)
print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
调用法语专家模型
messages = [
{'role': 'system', 'content': 'Vous êtes un assistant IA allemand sympathique et serviable'},
{'role': 'user', 'content': 'J\'aimerais faire du shopping à Paris. Que pouvez-vous recommander?'}
]
tokenizer = model.tokenizer
input_text = tokenizer.apply_chat_template(messages, tokenize=False)
print(input_text)
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
output_ids = model.generate(input_ids ,temperature=0.6, do_sample=True, top_p=0.9,top_k=20, max_length=250)
print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
调用斯堪的纳维亚语专家模型
messages = [
{'role': 'system', 'content': 'Du är en hjälpsam AI-assistent'},
{'role': 'user', 'content': 'Jag kommer från Tyskland och skulle vilja resa till Sverige. Är en färja över Danmark ett bra sätt att resa?'}
]
tokenizer = model.tokenizer
input_text = tokenizer.apply_chat_template(messages, tokenize=False)
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
output_ids = model.generate(input_ids ,temperature=0.1, do_sample=True, top_p=0.9,top_k=20, max_length=250)
print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
切换专家模型和量化设置
进入kraken_model
文件夹的配置文件,可进行如下设置:
"models": {
"expert1": "VAGOsolutions/Llama-3-SauerkrautLM-8b-Instruct", # 切换到你选择的德语/英语模型
"expert2": "mii-community/zefiro-7b-dpo-ITA", # 切换到你选择的意大利语模型
"expert3": "paulml/Hermes-2-Pro-French", # 切换到你选择的法语模型
"expert4": "norallm/normistral-7b-warm-instruct" # 切换到你选择的斯堪的纳维亚语模型
},
# 目前支持: "4bit","8bit" 和 "awq"
"quantization": {
"expert1": null,
"expert2": null,
"expert3": null,
"expert4": null
},
"router": "kraken_router",
# 根据你选择的模型调整分词器
"tokenizers": {
"expert1": "VAGOsolutions/Llama-3-SauerkrautLM-8b-Instruct",
"expert2": "mii-community/zefiro-7b-dpo-ITA",
"expert3": "paulml/Hermes-2-Pro-French",
"expert4": "norallm/normistral-7b-warm-instruct"
}
},
"model_type": "kraken",
"torch_dtype": "float32",
"transformers_version": "4.41.0"
}
✨ 主要特性
- 动态模型路由:使用序列分类模型,根据输入的特征将输入路由到最合适的语言模型。
- 多语言模型支持:支持集成各种预训练的因果语言模型,可根据上下文灵活响应。
- 可定制模板:支持使用预定义模板进行输入格式化,增强模型对不同对话上下文的适应性。
- 可扩展配置:采用自定义配置设置,可轻松扩展和适应各种因果语言建模用例。
📚 详细文档
模型概述
Kraken多语言模型及架构 Kraken 是 Cognitive Computations、VAGO Solutions 和 Hyperspace.ai 的 共同成果。由 Fernando Fernandes Neto、David Golchinfar、Lucas Atkins 和 Eric Hartford 创建。该模型支持德语、英语、意大利语、法语、瑞典语、芬兰语、丹麦语和挪威语。
Kraken架构是一个复杂的机器学习框架,专为动态文本生成任务设计。它利用Hugging Face的transformers库来协调多个因果语言模型(CLMs),并根据输入文本的上下文和内容智能地将输入路由到不同的模型。该架构由一个自定义配置类(KrakenConfig)驱动,便于集成和管理各种组件,如分词器、模型和路由机制。
选定的专家模型
"德语/英语专家": "VAGOsolutions/Llama-3-SauerkrautLM-8b-Instruct",
"意大利语功能专家": "mii-community/zefiro-7b-dpo-ITA",
"法语专家": "paulml/Hermes-2-Pro-French",
"斯堪的纳维亚语专家": "norallm/normistral-7b-warm-instruct",
📄 免责声明
我们必须告知用户,尽管我们在数据清理方面已尽最大努力,但仍不能完全排除未审查内容出现的可能性。我们无法保证模型始终表现恰当。因此,如果您遇到任何问题或发现不适当的内容,请通过提供的联系方式告知我们。此外,需要明确的是,这些模型的许可并不构成法律建议,我们不对使用我们模型的第三方的行为负责。
📞 联系我们
如果您对用于商业应用的定制大语言模型感兴趣,请通过我们的网站与我们联系。我们也非常感谢您的反馈和建议。
🤝 合作机会
我们热切寻求对我们的初创公司VAGO solutions和Hyperspace的支持和投资,我们在这两家公司不断推进强大语言模型的开发,以满足各种目的和需求。如果您对共同应对未来挑战感兴趣,我们诚挚地邀请您通过 VAGO solutions、Hyperspace.computer 和 Cognitive Computations 与我们联系。
📝 引用方式
Fernando Fernandes Neto, David Golchinfar, Lucas Atkins, Eric Hartford - Kraken: An OpenSource Collection of Experts Model, 2024



