Giter Site home page Giter Site logo

minigpt-4-zh's Introduction

MiniGPT-4中文支持方案

介绍

MiniGPT-4本身的语言大模型是基于LlaMA的,由于该模型对中文的支持不好。因此想了个折中的办法: 在模型的输入和输出分别加了一个翻译模型,用户输入(中文)-> 翻译模型(Chs-Eng) -> 大模型 -> 翻译模型(Eng-Chs)->返回结果

tokenizer_zh2en = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
model_zh2en = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M")

translatorEng2Zho = pipeline(
    'translation',
    model=model_zh2en,
    tokenizer=tokenizer_zh2en,
    src_lang='eng_Latn',
    tgt_lang='zho_Hans',
    max_length=1024
)

translatorZho2Eng = pipeline(
    'translation',
    model=model_zh2en,
    tokenizer=tokenizer_zh2en,
    tgt_lang='eng_Latn',
    src_lang='zho_Hans',
    max_length=1024
)

如何运行

python3 demo_zh.py --cfg-path eval_configs/minigpt4_eval.yaml  --gpu-id 0

效果图

demo

安装踩坑记录

  • RuntimeError: The size of tensor a (32000) must match the size of tensor b (32001) at non-singleton dimension 0 解决方案:vicuna模型需要下载vicuna-7b-delta-v1.1,老的模型会报错 参考 MiniGPT-4/issues/74 感谢 Cola1999 给与的支持!
  • Probability tensor contains either inf, nan or element < 0 解决方案:修改eval_configs/minigpt4_eval.yaml,将low_resource设置为False 参考MiniGPT-4/issues/74

TODO

  • 替换LlaMA模型为国产大模型,支持更高质量的中文交互

minigpt-4-zh's People

Contributors

tsutikgiau avatar xiaoqian-shen avatar lx709 avatar junchen14 avatar 152334h avatar snakehacker avatar zhwt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.