update the example for "Inference with Hugging Face library"

#1
by andrescodas - opened
Files changed (2) hide show
  1. LICENSE +0 -63
  2. README.md +15 -33
LICENSE DELETED
@@ -1,63 +0,0 @@
1
- MICROSOFT RESEARCH LICENSE TERMS
2
-
3
- IF YOU LIVE IN THE UNITED STATES, PLEASE READ THE “BINDING ARBITRATION AND CLASS ACTION WAIVER” SECTION BELOW. IT AFFECTS HOW DISPUTES ARE RESOLVED.
4
-
5
- These license terms are an agreement between you and Microsoft Corporation (or one of its affiliates). They apply to the source code, object code, machine learning models, or data (collectively “Materials”) that accompany this license. IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. BY USING THE MATERIALS, YOU ACCEPT THESE TERMS.
6
-
7
- 1) INSTALLATION AND USE RIGHTS TO THE MATERIALS.
8
-
9
- Subject to the terms of this agreement, you have the below rights, if applicable, to use the Materials solely for non-commercial, non-revenue generating, research purposes:
10
-
11
- a) Source Code. If source code is included, you may use and modify the source code, but you may not distribute the source code.
12
- b) Object Code. If object code is included, you may use the object code, but you may not distribute the object code.
13
- c) Models. If machine learning model(s) are included, you may use the model(s), but you may not distribute the models.
14
- d) Data. If data is included, you may use and modify the data, but your use and modification must be consistent with the consent under which the data was provided and/or gathered and you may not distribute the data or your modifications to the data.
15
-
16
- 2) SCOPE OF LICENSE. The Materials are licensed, not sold. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you will not (and have no right to):
17
-
18
- a) work around any technical limitations in the Materials that only allow you to use it in certain ways;
19
- b) reverse engineer, decompile or disassemble the Materials;
20
- c) remove, minimize, block, or modify any notices of Microsoft or its suppliers in the Materials;
21
- d) use the Materials in any way that is against the law or to create or propagate malware; or
22
- e) share, publish, distribute or lend the Materials, provide the Materials as a stand-alone hosted solution for others to use, or transfer the Materials or this agreement to any third party.
23
-
24
- 3) PERSONAL DATA. If the data (set forth in Section 1(c) above) includes or is found to include any data that enables any ability to identify an individual (“Personal Data”), you will not use such Personal Data for any purpose other than was authorized and consented to by the data subject/research participant. You will not use Personal Data to contact any person. You will keep Personal Data in strict confidence. You will not share any Personal Data that is collected or in your possession with any third party for any reason and as required under the original consent agreement. Further, you will destroy the Personal Data and any backup or copies, immediately upon the completion of your research.
25
-
26
- 4) LICENSE TO MICROSOFT. Notwithstanding the limitations in Section 1, you may distribute your modifications back to Microsoft, and if you do provide Microsoft with modifications of the Materials, you hereby grant Microsoft, without any restrictions or limitations, a non-exclusive, perpetual, irrevocable, royalty-free, assignable and sub-licensable license, to reproduce, publicly perform or display, install, use, modify, post, distribute, make and have made, sell and transfer such modifications and derivatives for any purpose.
27
-
28
- 5) PUBLICATION. You may publish (or present papers or articles) on your results from using the Materials provided that no material or substantial portion of the Materials is included in any such publication or presentation.
29
-
30
- 6) FEEDBACK. Any feedback about the Materials provided by you to us is voluntarily given, and Microsoft shall be free to use the feedback as it sees fit without obligation or restriction of any kind, even if the feedback is designated by you as confidential. Such feedback shall be considered a contribution and licensed to Microsoft under the terms of Section 4 above.
31
-
32
- 7) COMPLIANCE WITH TRADE LAWS. You acknowledge that the Materials may be subject to applicable trade laws in one or more countries. You will comply with all relevant laws and regulations applicable to the import or export of the Materials, including but not limited to, trade laws such as the U.S. Export Administration Regulations or other end-user, end use, and destination restrictions by the U.S. and other governments, as well as sanctions regulations administered by the U.S. Office of Foreign Assets Control. Microsoft may suspend or terminate the agreement immediately to the extent that Microsoft reasonably concludes that continued performance would violate trade laws or put it at risk of becoming subject to sanctions or penalties under trade laws. For additional information, see www.microsoft.com/exporting.
33
-
34
- 8) SUPPORT SERVICES. Microsoft is not obligated under this agreement to provide any support services for the Materials. Any support provided is “as is”, “with all faults”, and without warranty of any kind.
35
-
36
- 9) BINDING ARBITRATION AND CLASS ACTION WAIVER. This Section applies if you live in (or, if a business, your principal place of business is in) the United States. If you and Microsoft have a dispute, you and Microsoft agree to try for 60 days to resolve it informally. If you and Microsoft can’t, you and Microsoft agree to binding individual arbitration before the American Arbitration Association under the Federal Arbitration Act (“FAA”), and not to sue in court in front of a judge or jury. Instead, a neutral arbitrator will decide. Class action lawsuits, class-wide arbitrations, private attorney-general actions, and any other proceeding where someone acts in a representative capacity are not allowed; nor is combining individual proceedings without the consent of all parties. The complete Arbitration Agreement contains more terms and is at aka.ms/arb-agreement-1. You and Microsoft agree to these terms.
37
-
38
- 10) ENTIRE AGREEMENT. This agreement, and any other terms Microsoft may provide for supplements, updates, or third-party applications, is the entire agreement for the Materials.
39
-
40
- 11) APPLICABLE LAW AND PLACE TO RESOLVE DISPUTES. If you acquired the Materials in the United States or Canada, the laws of the state or province where you live (or, if a business, where your principal place of business is located) govern the interpretation of this agreement, claims for its breach, and all other claims (including consumer protection, unfair competition, and tort claims), regardless of conflict of laws principles, except that the FAA governs everything related to arbitration. If you acquired the Materials in any other country, its laws apply, except that the FAA governs everything related to arbitration. If U.S. federal jurisdiction exists, you and Microsoft consent to exclusive jurisdiction and venue in the federal court in King County, Washington for all disputes heard in court (excluding arbitration). If not, you and Microsoft consent to exclusive jurisdiction and venue in the Superior Court of King County, Washington for all disputes heard in court (excluding arbitration).
41
-
42
- 12) CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state, province, or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the Materials. This agreement does not change those other rights if the laws of your state, province, or country do not permit it to do so. For example, if you acquired the Materials in one of the below regions, or mandatory country law applies, then the following provisions apply to you:
43
-
44
- a) Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights.
45
-
46
- b) Canada. If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the Materials will resume checking for and installing updates), or uninstalling the Materials. The product documentation, if any, may also specify how to turn off updates for your specific device or software.
47
-
48
- c) Germany and Austria.
49
-
50
- i. Warranty. The properly licensed software will perform substantially as described in any Microsoft materials that accompany the Materials. However, Microsoft gives no contractual guarantee in relation to the licensed software.
51
-
52
- ii. Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as, in case of death or personal or physical injury, Microsoft is liable according to the statutory law.
53
-
54
- Subject to the foregoing clause (ii), Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence.
55
-
56
- 13) DISCLAIMER OF WARRANTY. THE MATERIALS ARE LICENSED “AS IS.” YOU BEAR THE RISK OF USING THEM. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO THE EXTENT PERMITTED UNDER APPLICABLE LAWS, MICROSOFT EXCLUDES ALL IMPLIED WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
57
-
58
- 14) LIMITATION ON AND EXCLUSION OF DAMAGES. IF YOU HAVE ANY BASIS FOR RECOVERING DAMAGES DESPITE THE PRECEDING DISCLAIMER OF WARRANTY, YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.
59
-
60
- This limitation applies to (a) anything related to the Materials, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, warranty, guarantee, or condition; strict liability, negligence, or other tort; or any other claim; in each case to the extent permitted by applicable law.
61
-
62
- It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state, province, or country may not allow the exclusion or limitation of incidental, consequential, or other damages.
63
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -4,24 +4,17 @@ tags:
4
  - orca
5
  - orca2
6
  - microsoft
7
- license: other
8
- license_name: microsoft-research-license
9
- license_link: LICENSE
10
  ---
11
 
12
  # Orca 2
13
 
14
  <!-- Provide a quick summary of what the model is/does. -->
15
 
16
- Orca 2 is built for research purposes only and provides a single turn response in tasks such as reasoning over user given data, reading comprehension, math problem solving and text summarization. The model is designed to excel particularly in reasoning.
 
 
17
 
18
- Note that:
19
-
20
- 1. This is a research model, intended to show that we can use capable models and complex workflows (advanced prompts, multiple calls) to create synthetic data that can teach Small Language Models (SLMs) new capabilities. We chose reasoning because it is a widely useful capability that SLMs lack.
21
- 2. The model is not optimized for chat and has not been trained with RLHF or DPO. It is best used after being finetuned for chat or for a specific task.
22
- 3. Beyond reasoning, the model inherits capabilities and limitations of its base (LLAMA-2 base). We have already seen that the benefits of the Orca training can be applied to other base model too.
23
-
24
- We make Orca 2's weights publicly available to support further research on the development, evaluation, and alignment of SLMs.
25
 
26
  ## What is Orca 2’s intended use(s)?
27
 
@@ -30,26 +23,25 @@ We make Orca 2's weights publicly available to support further research on the d
30
 
31
  ## How was Orca 2 evaluated?
32
 
33
- + Orca 2 has been evaluated on a large number of tasks ranging from reasoning to grounding and safety. Please refer
34
- to Section 6 and Appendix in the [Orca 2 paper](https://arxiv.org/pdf/2311.11045.pdf) for details on evaluations.
35
 
36
  ## Model Details
37
 
38
- Orca 2 is a finetuned version of LLAMA-2. Orca 2’s training data is a synthetic dataset that was created to enhance the small model’s reasoning abilities.
39
- All synthetic training data was moderated using the Microsoft Azure content filters. More details about the model can be found in the [Orca 2 paper](https://arxiv.org/pdf/2311.11045.pdf).
40
 
41
- Please refer to LLaMA-2 technical report for details on the model architecture.
42
 
43
  ## License
44
 
45
- Orca 2 is licensed under the [Microsoft Research License](LICENSE).
46
 
47
  Llama 2 is licensed under the [LLAMA 2 Community License](https://ai.meta.com/llama/license/), Copyright © Meta Platforms, Inc. All Rights Reserved.
48
 
49
  ## Bias, Risks, and Limitations
50
 
51
  Orca 2, built upon the LLaMA 2 model family, retains many of its limitations, as well as the
52
- common limitations of other large language models or limitation caused by its training
53
  process, including:
54
 
55
  **Data Biases**: Large language models, trained on extensive data, can inadvertently carry
@@ -129,6 +121,7 @@ tokenizer = transformers.AutoTokenizer.from_pretrained(
129
  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."
130
  user_message = "How can you determine if a restaurant is popular among locals or mainly attracts tourists, and why might this information be useful?"
131
 
 
132
  prompt = f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{user_message}<|im_end|>\n<|im_start|>assistant"
133
 
134
  inputs = tokenizer(prompt, return_tensors='pt')
@@ -155,9 +148,9 @@ print(second_turn_answer)
155
  **Safe inference with Azure AI Content Safety**
156
 
157
  The usage of [Azure AI Content Safety](https://azure.microsoft.com/en-us/products/ai-services/ai-content-safety/) on top of model prediction is strongly encouraged
158
- and can help preventing some of content harms. Azure AI Content Safety is a content moderation platform
159
- that uses AI to moderate content. By having Azure AI Content Safety on the output of Orca 2,
160
- the model output can be moderated by scanning it for different harm categories including sexual content, violence, hate, and
161
  self-harm with multiple severity levels and multi-lingual detection.
162
 
163
  ```python
@@ -218,6 +211,7 @@ tokenizer = transformers.AutoTokenizer.from_pretrained(
218
  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."
219
  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."
220
 
 
221
  prompt = f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{user_message}<|im_end|>\n<|im_start|>assistant"
222
 
223
  inputs = tokenizer(prompt, return_tensors='pt')
@@ -230,16 +224,4 @@ answers = tokenizer.batch_decode(new_output_ids, skip_special_tokens=True)
230
  final_output = answers[0] if not should_filter_out(answers[0]) else "[Content Filtered]"
231
 
232
  print(final_output)
233
- ```
234
-
235
- ## Citation
236
- ```bibtex
237
- @misc{mitra2023orca,
238
- title={Orca 2: Teaching Small Language Models How to Reason},
239
- 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},
240
- year={2023},
241
- eprint={2311.11045},
242
- archivePrefix={arXiv},
243
- primaryClass={cs.AI}
244
- }
245
  ```
 
4
  - orca
5
  - orca2
6
  - microsoft
 
 
 
7
  ---
8
 
9
  # Orca 2
10
 
11
  <!-- Provide a quick summary of what the model is/does. -->
12
 
13
+ Orca 2 is a helpful assistant that is built for research purposes only and provides a single turn response
14
+ in tasks such as reasoning over user given data, reading comprehension, math problem solving and text summarization.
15
+ The model is designed to excel particularly in reasoning.
16
 
17
+ We open-source Orca 2 to encourage further research on the development, evaluation, and alignment of smaller LMs.
 
 
 
 
 
 
18
 
19
  ## What is Orca 2’s intended use(s)?
20
 
 
23
 
24
  ## How was Orca 2 evaluated?
25
 
26
+ + Orca 2 has been evaluated on a large number of tasks ranging from reasoning to safety. Please refer to Section 6 and Appendix in the paper for details on evaluations.
 
27
 
28
  ## Model Details
29
 
30
+ Orca 2 is a finetuned version of LLAMA-2. Orca 2’s training data is a synthetic dataset that was created to enhance the small model’s reasoning abilities. All synthetic training data was filtered using the Azure content filters.
31
+ More details about the model can be found at: LINK to Tech Report
32
 
33
+ Refer to LLaMA-2 for details on model architectures.
34
 
35
  ## License
36
 
37
+ Orca 2 is licensed under the [Microsoft Research License]().
38
 
39
  Llama 2 is licensed under the [LLAMA 2 Community License](https://ai.meta.com/llama/license/), Copyright © Meta Platforms, Inc. All Rights Reserved.
40
 
41
  ## Bias, Risks, and Limitations
42
 
43
  Orca 2, built upon the LLaMA 2 model family, retains many of its limitations, as well as the
44
+ common limitations of other large language models or limitation including by its training
45
  process, including:
46
 
47
  **Data Biases**: Large language models, trained on extensive data, can inadvertently carry
 
121
  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."
122
  user_message = "How can you determine if a restaurant is popular among locals or mainly attracts tourists, and why might this information be useful?"
123
 
124
+ # We use Chat Markup Language https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/ai-services/openai/includes/chat-markup-language.md#working-with-chat-markup-language-chatml
125
  prompt = f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{user_message}<|im_end|>\n<|im_start|>assistant"
126
 
127
  inputs = tokenizer(prompt, return_tensors='pt')
 
148
  **Safe inference with Azure AI Content Safety**
149
 
150
  The usage of [Azure AI Content Safety](https://azure.microsoft.com/en-us/products/ai-services/ai-content-safety/) on top of model prediction is strongly encouraged
151
+ and can help prevent content harms. Azure AI Content Safety is a content moderation platform
152
+ that uses AI to keep your content safe. By integrating Orca 2 with Azure AI Content Safety,
153
+ we can moderate the model output by scanning it for sexual content, violence, hate, and
154
  self-harm with multiple severity levels and multi-lingual detection.
155
 
156
  ```python
 
211
  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."
212
  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."
213
 
214
+ # We use Chat Markup Language https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/ai-services/openai/includes/chat-markup-language.md#working-with-chat-markup-language-chatml
215
  prompt = f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{user_message}<|im_end|>\n<|im_start|>assistant"
216
 
217
  inputs = tokenizer(prompt, return_tensors='pt')
 
224
  final_output = answers[0] if not should_filter_out(answers[0]) else "[Content Filtered]"
225
 
226
  print(final_output)
 
 
 
 
 
 
 
 
 
 
 
 
227
  ```