Orca 2 13b
模型概述
Orca 2專為研究目的設計,擅長數據推理、閱讀理解、數學問題求解和文本摘要等任務。該模型通過合成數據訓練,特別優化了推理能力。
模型特點
增強推理能力
通過合成數據訓練,顯著提升小型語言模型的推理能力
研究導向設計
專為研究社區評估模型能力和推動前沿模型發展而構建
安全措施
訓練數據經過Azure內容過濾器審核,並建議使用Azure AI內容安全進行輸出審核
模型能力
數據推理
閱讀理解
數學問題求解
文本摘要
單輪對話響應
使用案例
學術研究
語言模型能力評估
用於評估小型語言模型在推理任務上的表現
提供基準測試結果,支持研究論文
教育輔助
數學問題解答
幫助學生理解和解決數學問題
提供分步解答和推理過程
🚀 Orca 2
Orca 2專為研究目的而構建,可在諸如對用戶給定數據進行推理、閱讀理解、解決數學問題和文本摘要等任務中提供單輪響應。該模型尤其在推理方面表現出色。
🚀 快速開始
使用Hugging Face庫進行推理
import torch
import transformers
if torch.cuda.is_available():
torch.set_default_device("cuda")
else:
torch.set_default_device("cpu")
model = transformers.AutoModelForCausalLM.from_pretrained("microsoft/Orca-2-13b", device_map='auto')
# https://github.com/huggingface/transformers/issues/27132
# please use the slow tokenizer since fast and slow tokenizer produces different tokens
tokenizer = transformers.AutoTokenizer.from_pretrained(
"microsoft/Orca-2-13b",
use_fast=False,
)
system_message = "You are Orca, an AI language model created by Microsoft. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior."
user_message = "How can you determine if a restaurant is popular among locals or mainly attracts tourists, and why might this information be useful?"
prompt = f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{user_message}<|im_end|>\n<|im_start|>assistant"
inputs = tokenizer(prompt, return_tensors='pt')
output_ids = model.generate(inputs["input_ids"],)
answer = tokenizer.batch_decode(output_ids)[0]
print(answer)
# This example continues showing how to add a second turn message by the user to the conversation
second_turn_user_message = "Give me a list of the key points of your first answer."
# we set add_special_tokens=False because we dont want to automatically add a bos_token between messages
second_turn_message_in_markup = f"\n<|im_start|>user\n{second_turn_user_message}<|im_end|>\n<|im_start|>assistant"
second_turn_tokens = tokenizer(second_turn_message_in_markup, return_tensors='pt', add_special_tokens=False)
second_turn_input = torch.cat([output_ids, second_turn_tokens['input_ids']], dim=1)
output_ids_2 = model.generate(second_turn_input,)
second_turn_answer = tokenizer.batch_decode(output_ids_2)[0]
print(second_turn_answer)
使用Azure AI Content Safety進行安全推理
強烈建議在模型預測的基礎上使用Azure AI Content Safety,這有助於防止內容危害。Azure AI Content Safety是一個內容審核平臺,利用人工智能確保內容安全。通過將Orca 2與Azure AI Content Safety集成,我們可以對模型輸出進行審核,掃描其中是否包含不同嚴重程度的性內容、暴力、仇恨和自殘相關內容,並支持多語言檢測。
import os
import math
import transformers
import torch
from azure.ai.contentsafety import ContentSafetyClient
from azure.core.credentials import AzureKeyCredential
from azure.core.exceptions import HttpResponseError
from azure.ai.contentsafety.models import AnalyzeTextOptions
CONTENT_SAFETY_KEY = os.environ["CONTENT_SAFETY_KEY"]
CONTENT_SAFETY_ENDPOINT = os.environ["CONTENT_SAFETY_ENDPOINT"]
# We use Azure AI Content Safety to filter out any content that reaches "Medium" threshold
# For more information: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/
def should_filter_out(input_text, threshold=4):
# Create an Content Safety client
client = ContentSafetyClient(CONTENT_SAFETY_ENDPOINT, AzureKeyCredential(CONTENT_SAFETY_KEY))
# Construct a request
request = AnalyzeTextOptions(text=input_text)
# Analyze text
try:
response = client.analyze_text(request)
except HttpResponseError as e:
print("Analyze text failed.")
if e.error:
print(f"Error code: {e.error.code}")
print(f"Error message: {e.error.message}")
raise
print(e)
raise
categories = ["hate_result", "self_harm_result", "sexual_result", "violence_result"]
max_score = -math.inf
for category in categories:
max_score = max(max_score, getattr(response, category).severity)
return max_score >= threshold
model_path = 'microsoft/Orca-2-13b'
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model = transformers.AutoModelForCausalLM.from_pretrained(model_path)
model.to(device)
tokenizer = transformers.AutoTokenizer.from_pretrained(
model_path,
model_max_length=4096,
padding_side="right",
use_fast=False,
add_special_tokens=False,
)
system_message = "You are Orca, an AI language model created by Microsoft. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior."
user_message = "\" \n :You can't just say, \"\"that's crap\"\" and remove it without gaining a consensus. You already know this, based on your block history. —/ \" \nIs the comment obscene? \nOptions : Yes, No."
prompt = f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{user_message}<|im_end|>\n<|im_start|>assistant"
inputs = tokenizer(prompt, return_tensors='pt')
inputs = inputs.to(device)
output_ids = model.generate(inputs["input_ids"], max_length=4096, do_sample=False, temperature=0.0, use_cache=True)
sequence_length = inputs["input_ids"].shape[1]
new_output_ids = output_ids[:, sequence_length:]
answers = tokenizer.batch_decode(new_output_ids, skip_special_tokens=True)
final_output = answers[0] if not should_filter_out(answers[0]) else "[Content Filtered]"
print(final_output)
✨ 主要特性
- 專為研究目的而構建,在推理任務中表現出色。
- 可在推理、閱讀理解、數學問題解決和文本摘要等任務中提供單輪響應。
📚 詳細文檔
Orca 2的預期用途
- Orca 2僅用於研究目的。
- 主要目的是讓研究社區評估其能力,併為構建更好的前沿模型提供基礎。
Orca 2的評估方式
Orca 2已在從推理到基礎和安全等大量任務上進行了評估。詳情請參考Orca 2論文的第6節和附錄。
模型詳情
Orca 2是LLAMA - 2的微調版本。Orca 2的訓練數據是一個合成數據集,旨在增強小模型的推理能力。所有合成訓練數據均使用Microsoft Azure內容過濾器進行了審核。有關該模型的更多詳細信息可在Orca 2論文中找到。模型架構的詳細信息請參考LLaMA - 2技術報告。
許可證
- Orca 2遵循Microsoft Research License。
- Llama 2遵循LLAMA 2 Community License,版權所有 © Meta Platforms, Inc. 保留所有權利。
偏差、風險和侷限性
Orca 2基於LLaMA 2模型家族構建,保留了其許多侷限性,以及其他大語言模型的常見侷限性或由其訓練過程導致的侷限性,包括:
- 數據偏差:大語言模型在大量數據上進行訓練,可能會無意中攜帶源數據中存在的偏差。因此,模型可能會生成有潛在偏差或不公平的輸出。
- 缺乏上下文理解:儘管這些模型在語言理解和生成方面具有令人印象深刻的能力,但它們對現實世界的理解有限,可能導致輸出不準確或無意義。
- 缺乏透明度:由於模型的複雜性和規模,大語言模型可能像“黑匣子”一樣,難以理解特定輸出或決策背後的原理。建議查看Azure的透明度說明以獲取更多信息。
- 內容危害:大語言模型可能會造成各種類型的內容危害。使用這些模型時,瞭解這些危害並採取措施預防非常重要。建議利用不同公司和機構提供的各種內容審核服務。重要的是,我們希望未來政府和科技領袖能針對人工智能技術的內容危害制定更好的法規和標準。我們重視並認可研究和開源社區在這方面可以發揮的重要作用。
- 幻覺現象:重要的是要意識到並謹慎對待,不要完全依賴給定的語言模型來做出關鍵決策或獲取可能有深遠影響的信息,因為目前尚不清楚如何防止這些模型編造內容。此外,由於小模型規模較小、記憶能力有限,在無根據的生成用例中,它們是否更容易出現幻覺現象也尚不清楚。這是一個活躍的研究課題,我們希望在這個課題上能有更嚴格的測量、理解和緩解措施。
- 潛在的濫用風險:如果沒有適當的保障措施,這些模型有可能被惡意用於生成虛假信息或有害內容。
- 數據分佈:Orca 2的性能可能與微調數據的分佈密切相關。這種相關性可能會限制其在訓練數據中代表性不足的領域(如數學、編碼和推理)的準確性。
- 系統消息:Orca 2的性能會因系統指令的不同而有所差異。此外,模型規模引入的隨機性可能導致對不同系統指令生成非確定性的響應。
- 零樣本設置:Orca 2主要在模擬零樣本設置的數據上進行訓練。雖然該模型在零樣本設置中表現非常出色,但與其他模型(特別是更大的模型)相比,它在少樣本學習方面的優勢並不明顯。
- 合成數據:由於Orca 2在合成數據上進行訓練,它可能繼承了用於數據生成的模型和方法的優點和缺點。我們認為Orca 2受益於訓練過程中納入的安全措施和Azure OpenAI API中的安全防護欄(如內容過濾器)。然而,需要進行詳細研究以更好地量化此類風險。
此模型僅設計用於研究環境,並且僅在該環境中進行了測試。不應用於下游應用,因為需要進行額外的分析來評估其在擬議應用中可能造成的危害或偏差。
📄 許可證
Orca 2遵循Microsoft Research License。Llama 2遵循LLAMA 2 Community License,版權所有 © Meta Platforms, Inc. 保留所有權利。
📚 引用
@misc{mitra2023orca,
title={Orca 2: Teaching Small Language Models How to Reason},
author={Arindam Mitra and Luciano Del Corro and Shweti Mahajan and Andres Codas and Clarisse Simoes and Sahaj Agrawal and Xuxi Chen and Anastasia Razdaibiedina and Erik Jones and Kriti Aggarwal and Hamid Palangi and Guoqing Zheng and Corby Rosset and Hamed Khanpour and Ahmed Awadallah},
year={2023},
eprint={2311.11045},
archivePrefix={arXiv},
primaryClass={cs.AI}
}
Phi 2 GGUF
其他
Phi-2是微軟開發的一個小型但強大的語言模型,具有27億參數,專注於高效推理和高質量文本生成。
大型語言模型 支持多種語言
P
TheBloke
41.5M
205
Roberta Large
MIT
基於掩碼語言建模目標預訓練的大型英語語言模型,採用改進的BERT訓練方法
大型語言模型 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基礎模型的蒸餾版本,在保持相近性能的同時更輕量高效,適用於序列分類、標記分類等自然語言處理任務。
大型語言模型 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一個多語言大語言模型,針對多語言對話用例進行了優化,在常見的行業基準測試中表現優異。
大型語言模型 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基於100種語言的2.5TB過濾CommonCrawl數據預訓練的多語言模型,採用掩碼語言建模目標進行訓練。
大型語言模型 支持多種語言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基於Transformer架構的英語預訓練模型,通過掩碼語言建模目標在海量文本上訓練,支持文本特徵提取和下游任務微調
大型語言模型 英語
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI發佈的開放預訓練Transformer語言模型套件,參數量從1.25億到1750億,旨在對標GPT-3系列性能,同時促進大規模語言模型的開放研究。
大型語言模型 英語
O
facebook
6.3M
198
1
基於transformers庫的預訓練模型,適用於多種NLP任務
大型語言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多語言大語言模型系列,包含8B、70B和405B參數規模,支持8種語言和代碼生成,優化了多語言對話場景。
大型語言模型
Transformers 支持多種語言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基礎版是由Google開發的文本到文本轉換Transformer模型,參數規模2.2億,支持多語言NLP任務。
大型語言模型 支持多種語言
T
google-t5
5.4M
702
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98