**Huggingface Guide**

If you are interested in learning more about MiniCPM, a series of end-size large language models developed by ModelBest Inc. and TsinghuaNLP, this guide will provide you with all the necessary information.

**Technical Reports and Models**
– You can access the MiniCPM technical report [here](https://shengdinghu.notion.site/MiniCPM-c805a17c5c8046398914e47f0542095a?pvs=4).
– Explore the OmniLMM Multi-modal Model [here](https://github.com/OpenBMB/OmniLMM/).
– For trial use of the CPM-C ~100B Model, visit this https://huggingface.co/openbmb/MiniCPM-2B-sft-fp32(https://luca.cn/).

**Overview of MiniCPM**
– MiniCPM-2B is the main language model with only 2.4B parameters.
– MiniCPM has been evaluated and performs strongly in various benchmarks, outperforming other large language models.

**Features of MiniCPM**
– MiniCPM has been enhanced through SFT and DPO, leading to improved performance on public evaluation sets.
– The development of MiniCPM-V, a multi-modal model based on MiniCPM-2B, exhibits superior overall performance.
– MiniCPM is deployable on smartphones and demonstrates high-speed, real-time streaming output.

**Open Source and License**
– MiniCPM-2B parameters and training checkpoints are available for research and limited commercial use.
– Various versions of MiniCPM, such as SFT/DPO, Int4 quantized, and mobile phone applications, are open-source.

**Evaluation Results and Limitations**
– Detailed evaluation results can be found on the [GitHub repository](https://github.com/OpenBMB/MiniCPM?tab=readme-ov-file#%E8%AF%84%E6%B5%8B%E7%BB%93%E6%9E%9C).
– Caution is advised when using Huggingface for generation, as the quality has been found to be slightly lower than vLLM.

**Model Download and Usage**
– You can download the MiniCPM models and follow the usage guide provided in this section.

**Statement and Citation**
– A statement regarding the limitations of the model is presented, highlighting factors such as hallucinatory issues and prompt word influence.
– The guide also includes a citation for referencing work related to MiniCPM.

For further information and technical details, refer to the complete guide above for a comprehensive understanding of MiniCPM and its capabilities.

Source link
# Huggingface Tutorial

## Introduction
Huggingface is a platform that provides state-of-the-art natural language processing (NLP) models, allowing users to easily access and utilize these models for various NLP tasks.

## Getting Started
To begin using Huggingface, you can visit their official website at [Huggingface](https://huggingface.co/) to explore the available models and resources.

## Model Options
Huggingface offers a wide range of language models including MiniCPM, OmniLMM, and CPM-C. Each of these models has specific characteristics and can be used for different NLP tasks.

## Evaluating Performance
Detailed evaluation results for the models can be found in the respective GitHub repositories:
– [MiniCPM Evaluation Results](https://github.com/OpenBMB/MiniCPM?tab=readme-ov-file#%E8%AF%84%E6%B5%8B%E7%BB%93%E6%9E%9C)
– [OmniLMM Evaluation Results](https://github.com/OpenBMB/OmniLMM/blob/main/README-en.md#evaluation-results)
– [CPM-C Evaluation Results](https://github.com/OpenBMB/MiniCPM/blob/main/README-en.md#evaluation-results)

## Limitations
It’s important to note that there are limitations to the models due to their size and training data. These limitations include hallucinatory issues and prompt word sensitivity. Users should be aware of these limitations when using the models for NLP tasks.

## Downloading Models
To download the models, you can visit the respective GitHub repositories and follow the instructions provided for model download and usage.

## Using the Models
Once the models are downloaded, you can use them by installing the required dependencies such as `transformers>=4.36.0` and `accelerate`. After installation, you can run the provided code snippets to utilize the models for various NLP tasks. It’s important to specify the data type of the model clearly in the `from_pretrained` function to avoid calculation errors.

## Licensing and Citations
The model parameters and usage are governed by specific licenses, and it’s important to review and adhere to these licenses when using the models. Additionally, when citing the models in academic work, it’s recommended to include the appropriate citation format provided in the respective GitHub repositories.

## Conclusion
In conclusion, Huggingface provides access to powerful language models such as MiniCPM, OmniLMM, and CPM-C, along with detailed evaluation results and guidance on using these models for NLP tasks. Users should be mindful of the limitations and licensing conditions when utilizing these resources.

MiniCPM 技术报告 Technical Report |
OmniLMM 多模态模型 Multi-modal Model |
CPM-C 千亿模型试用 ~100B Model Trial

MiniCPM 是面壁与清华大学自然语言处理实验室共同开源的系列端侧语言大模型,主体语言模型 MiniCPM-2B 仅有 24亿(2.4B)的非词嵌入参数量。

  • 经过 SFT 后,MiniCPM 在公开综合性评测集上,MiniCPM 与 Mistral-7B相近(中文、数学、代码能力更优),整体性能超越 Llama2-13B、MPT-30B、Falcon-40B 等模型。
  • 经过 DPO 后,MiniCPM 在当前最接近用户体感的评测集 MTBench上,MiniCPM-2B 也超越了 Llama2-70B-Chat、Vicuna-33B、Mistral-7B-Instruct-v0.1、Zephyr-7B-alpha 等众多代表性开源大模型。
  • 以 MiniCPM-2B 为基础构建端侧多模态大模型 MiniCPM-V,整体性能在同规模模型中实现最佳,超越基于 Phi-2 构建的现有多模态大模型,在部分评测集上达到与 9.6B Qwen-VL-Chat 相当甚至更好的性能。
  • 经过 Int4 量化后,MiniCPM 可在手机上进行部署推理,流式输出速度略高于人类说话速度。MiniCPM-V 也首次跑通了多模态大模型在手机上的部署。
  • 一张1080/2080可高效参数微调,一张3090/4090可全参数微调,一台机器可持续训练 MiniCPM,二次开发成本较低。

我们将完全开源MiniCPM-2B的模型参数供学术研究和有限商用,以及训练过程中的所有Checkpoint和大部分非专有数据供模型机理研究。

  • 基于MiniCPM-2B的指令微调与人类偏好对MiniCPM-2B-SFT/DPO。
  • 基于MiniCPM-2B的多模态模型MiniCPM-V,能力超越基于Phi-2的同参数级别多模态模型
  • MiniCPM-2B-SFT/DPO的Int4量化版MiniCPM-2B-SFT/DPO-Int4。
  • 基于MLC-LLM、LLMFarm开发的MiniCPM手机端程序,文本及多模态模型均可在手机端进行推理。

MiniCPM is an End-Size LLM developed by ModelBest Inc. and TsinghuaNLP, with only 2.4B parameters excluding embeddings.

  • MiniCPM has very close performance compared with Mistral-7B on open-sourced general benchmarks with better ability on Chinese, Mathmetics and Coding after SFT. The overall performance exceeds Llama2-13B, MPT-30B, Falcon-40B, etc.
  • After DPO, MiniCPM outperforms Llama2-70B-Chat, Vicuna-33B, Mistral-7B-Instruct-v0.1, Zephyr-7B-alpha, etc. on MTBench.
  • MiniCPM-V, based on MiniCPM-2B, achieves the best overall performance among multimodel models of the same scale, surpassing existing multimodal large models built on Phi-2 and achieving performance comparable to or even better than 9.6B Qwen-VL-Chat on some tasks.
  • MiniCPM can be deployed and infer on smartphones, and the speed of streaming output is relatively higher than the verbal speed of human. MiniCPM-V is the first multi-modal models that can be deployed on smartphones.
  • The cost of developing based on MiniCPM is low. Parameter efficient finetuning can be conducted with a single 1080/2080 GPU and full parameter finetuning can be conducted with a 3090/4090 GPU.

We release all model parameters for research and limited commercial use. We also release all the checkpoint during training and most public training data for research on model mechanism.

  • SFT and DPO version based on MiniCPM-2B and human preference: MiniCPM-2B-SFT/DPO
  • The multi-modal model MiniCPM-V based on MiniCPM-2B, which outperforms models with similar size, i.e., Phi-2
  • The INT4 quantized version MiniCPM-2B-SFT/DPO-Int4 based on MiniCPM-2B-SFT/DPO
  • Mobile phone application based on MLC-LLM and LLMFarm. Both language model and multimodel model can conduct inference on smartphones.



评测结果 Evaluation Results

详细的评测结果位于github仓库

Detailed evaluation results are in github repo

注意:我们发现使用Huggingface生成质量略差于vLLM,因此推荐使用vLLM进行测试。我们正在排查原因。

Notice: We discovered that the quality of Huggingface generation is slightly lower than vLLM, thus benchmarking using vLLM is recommended.
We are investigating the cause now.



局限性 Limitations

  • 受限于模型规模,模型可能出现幻觉性问题。其中由于DPO模型生成的回复内容更长,更容易出现幻觉。我们也将持续进行MiniCPM模型的迭代改进;

  • 为了保证在学术研究用途上模型的通用性,我们未对模型进行任何身份认同训练。同时由于我们用ShareGPT开源语料作为部分训练数据,模型可能会输出类似GPT系列模型的身份认同信息;

  • 受限于模型规模,模型的输出受到提示词(prompt)的影响较大,可能多次尝试产生不一致的结果;

  • 受限于模型容量,模型的知识记忆较不准确,后续我们将结合RAG方法来增强模型的知识记忆能力。

  • Due to limitations in model size, the model may experience hallucinatory issues. As DPO model tend to generate longer response, hallucinations are more likely to occur. We will also continue to iterate and improve the MiniCPM model.

  • To ensure the universality of the model for academic research purposes, we did not conduct any identity training on the model. Meanwhile, as we use ShareGPT open-source corpus as part of the training data, the model may output identity information similar to the GPT series models.

  • Due to the limitation of model size, the output of the model is greatly influenced by prompt words, which may result in inconsistent results from multiple attempts.

  • Due to limited model capacity, the model’s knowledge memory is not accurate. In the future, we will combine the RAG method to enhance the model’s knowledge memory ability.



模型下载 Download



模型使用 Usage

  • 安装transformers>=4.36.0以及accelerate后,运行以下代码
  • 注意:需要在from_pretrained中明确指明模型的数据类型,否则会引起较大计算误差
  • Run the following code after install transformers>=4.36.0 and accelerate
  • Warning: It is necessary to specify the data type of the model clearly in ‘from_pretrained’, otherwise large calculation errors will be caused
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
torch.manual_seed(0)

path = 'openbmb/MiniCPM-2B-sft-fp32'
tokenizer = AutoTokenizer.from_pretrained(path)
model = AutoModelForCausalLM.from_pretrained(path, torch_dtype=torch.float32, device_map='cuda', trust_remote_code=True)

responds, history = model.chat(tokenizer, "山东省最高的山是哪座山, 它比黄山高还是矮?差距多少?", temperature=0.8, top_p=0.8)
print(responds)
  • 期望输出 Expected Output
山东省最高的山是泰山,海拔1545米。

相对于黄山(海拔1864米),泰山海拔较低,相差约319米。



开源协议 LICENSE



模型协议 Model LICENSE



声明 Statement

  • 作为一个语言模型,MiniCPM 通过学习大量的文本来生成内容,但它无法理解、表达个人观点或价值判断,它所输出的任何内容都不代表模型开发者的观点和立场。

  • 因此用户在使用 MiniCPM 生成的内容时,应自行负责对其进行评估和验证。

  • 如果由于使用 MinCPM 开源模型而导致的任何问题,包括但不限于数据安全问题、公共舆论风险,或模型被误导、滥用、传播或不当利用所带来的任何风险和问题,我们将不承担任何责任。

  • As a language model, MiniCPM generates content by learning from a vast amount of text.

  • However, it does not possess the ability to comprehend or express personal opinions or value judgments.

  • Any content generated by MiniCPM does not represent the viewpoints or positions of the model developers.

  • Therefore, when using content generated by MiniCPM, users should take full responsibility for evaluating and verifying it on their own.



工作引用 Citation

@inproceedings{minicpm2024,
 title={MiniCPM:Unveiling the Potential of End-side Large Language Models},
 booktitle={OpenBMB Blog},
 year={2024}
}

The

tag in HTML is a versatile and powerful tool that can be used for a variety of purposes across different domains. Here are some common use cases for the

tag:

1. Structuring Content: The

tag is often used to create sections within a webpage. It can be used to group and organize related content, such as text, images, and other HTML elements. This can help improve the overall layout and readability of the webpage.

2. Styling and Positioning: With the help of CSS, the

tag can be used to apply styling and positioning to specific sections of a webpage. This can include defining background colors, borders, margins, and padding, as well as controlling the position of elements within the layout.

3. Creating Containers: The

tag can be used to create containers for other HTML elements, such as forms, buttons, or lists. These containers can help keep related elements visually grouped together and make it easier to style and manipulate them.

4. Building Frameworks: The

tag is a fundamental building block for creating responsive web design frameworks. It is often used to create grid systems, columns, and sections that help to structure the layout of a webpage across different screen sizes and devices.

5. Embedding Third-Party Content: The

tag can be used to embed third-party content, such as videos, maps, or social media feeds, into a webpage. This allows for the seamless integration of external content within the overall structure of the page.

6. Script Integration: JavaScript frameworks and libraries often require specific containers for their functionality. The

tag can be used to create these containers and provide a space for integrating interactive components, such as sliders, carousels, or interactive forms.

7. Creating Modals and Overlays: When implementing modal pop-ups, lightboxes, or overlay components, the

tag can be used to create the container for these elements. This allows for the display of temporary or additional content on top of the main webpage content.

8. Organizing Content in Data Storage: The

tag can be used to organize and structure content within a database. For example, it can help to group related data fields or to create visually distinct sections within a database interface.

Overall, the

tag is a fundamental element in HTML that serves a wide range of use cases across web development, content organization, user interface design, and more. It provides a flexible and versatile way to structure and organize content within a webpage, making it an essential tool for web developers and designers.

2024-02-11T21:03:19+01:00