{"id":1788,"date":"2023-10-31T00:55:46","date_gmt":"2023-10-30T15:55:46","guid":{"rendered":"https:\/\/fukugyouhistory.tokyo\/?p=1788"},"modified":"2023-11-08T06:38:51","modified_gmt":"2023-11-07T21:38:51","slug":"%e4%b8%ad%e5%9b%bd%e7%99%ba%e3%81%aellm-xwin-lm%e3%80%80%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab%e7%92%b0%e5%a2%83%e3%81%a7%e5%8b%95%e3%81%8b%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/fukugyouhistory.tokyo\/?p=1788","title":{"rendered":"\u4e2d\u56fd\u767a\u306eLLM Xwin-LM\u3000\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u52d5\u304b\u3057\u3066\u307f\u305f"},"content":{"rendered":"\n<p>2023\u5e749\u6708\u306bOpenAI\u306e\u751f\u6210AI\u300cGPT-4\u300d\u3092\u4e0a\u56de\u308b\u6027\u80fd\u3092\u3046\u305f\u3063\u3066\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305fXwin-LM\u3002<br>\u4e2d\u56fd\u79d1\u5b66\u9662\u3084\u6e05\u83ef\u5927\u5b66\u306e\u7814\u7a76\u8005\u3089\u304c\u958b\u767a\u3057\u305f\u3088\u3046\u3067\u3059\u3002\u30ed\u30b4\u683c\u597d\u3088\u3057\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-dominant-color=\"d0d0d2\" data-has-transparency=\"false\" decoding=\"async\" width=\"1024\" height=\"305\" sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"https:\/\/fukugyouhistory.tokyo\/wp-content\/uploads\/2023\/10\/image-1024x305.webp\" alt=\"\" class=\"wp-image-1793 not-transparent\" style=\"--dominant-color: #d0d0d2; aspect-ratio:3.357377049180328;width:352px;height:auto\" srcset=\"https:\/\/fukugyouhistory.tokyo\/wp-content\/uploads\/2023\/10\/image-1024x305.webp 1024w, https:\/\/fukugyouhistory.tokyo\/wp-content\/uploads\/2023\/10\/image-300x89.webp 300w, https:\/\/fukugyouhistory.tokyo\/wp-content\/uploads\/2023\/10\/image-768x229.webp 768w, https:\/\/fukugyouhistory.tokyo\/wp-content\/uploads\/2023\/10\/image-1536x458.webp 1536w, https:\/\/fukugyouhistory.tokyo\/wp-content\/uploads\/2023\/10\/image-jpg.webp 1665w\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img data-dominant-color=\"f4f5f6\" data-has-transparency=\"true\" decoding=\"async\" width=\"754\" height=\"495\" sizes=\"(max-width: 754px) 100vw, 754px\" src=\"https:\/\/fukugyouhistory.tokyo\/wp-content\/uploads\/2023\/10\/image.png\" alt=\"\" class=\"wp-image-1795 has-transparency\" style=\"--dominant-color: #f4f5f6; aspect-ratio:1.5232323232323233;width:473px;height:auto\" srcset=\"https:\/\/fukugyouhistory.tokyo\/wp-content\/uploads\/2023\/10\/image.png 754w, https:\/\/fukugyouhistory.tokyo\/wp-content\/uploads\/2023\/10\/image-300x197.png 300w\" \/><\/figure>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/Xwin-LM\/Xwin-LM\/tree\/main\" data-type=\"link\" data-id=\"https:\/\/github.com\/Xwin-LM\/Xwin-LM\/tree\/main\" target=\"_blank\">GitHub<\/a>\u3001<a rel=\"noreferrer noopener\" href=\"https:\/\/huggingface.co\/Xwin-LM\/Xwin-LM-7B-V0.2\" data-type=\"link\" data-id=\"https:\/\/huggingface.co\/Xwin-LM\/Xwin-LM-7B-V0.2\" target=\"_blank\">Hugging Face<\/a>\u4e0a\u3067\u516c\u958b\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u5b9f\u969b\u306b\u4f7f\u3063\u3066\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>Google Colabolatory\u306e\u7121\u6599\u67a0\u3067\u306f\u5b9f\u884c\u3067\u304d\u305d\u3046\u306b\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u30e1\u30e2\u30ea64GB\u7a4d\u3093\u3060PC\u3092\u7528\u3044\u3066\u3001<br>Ctranslate2\u3092\u7528\u3044\u3066\u30b3\u30f3\u30d0\u30fc\u30c8\u3057\u3001GPU\u306a\u3057\u3067\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u65e9\u901f\u3001\u4e0b\u8a18\u306b\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u3001\u30b3\u30f3\u30d0\u30fc\u30c8\u3059\u308b\u305f\u3081\u306e\u30b3\u30de\u30f3\u30c9\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!pip install ctranslate2\n!pip install sentencepiece transformers\n!ct2-transformers-converter \\\n    --model Xwin-LM\/Xwin-LM-7B-V0.2 \\\n    --quantization int8 \\\n    --output_dir .\/Xwin-LM-7B-V0.2 \\\n    --low_cpu_mem_usage<\/code><\/pre>\n\n\n\n<p>\u203b\u300cYou are using the default legacy behaviour of the &lt;class \u2026\u300d\u3068\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u51fa\u307e\u3059\u304c\u3001<br>\u3000\u3068\u308a\u3042\u3048\u305a\u300c\u2013output_dir\u300d\u3067\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u306b\u30013\u500b\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u554f\u984c\u306a\u304f\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u306f\u305a\u3067\u3059\u3002<br>\u3000\uff08config.json\u3001model.bin\u3001vocabulary.txt\uff09<br>\u3000\u4e0b\u8a18\u306etokenizer\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u300clegacy=False\u300d\u3092\u5165\u308c\u308b\u3053\u3068\u3067\u3001\u30e2\u30c7\u30eb\u5b9f\u884c\u6642\u306b\u306f\u4e0a\u8a18\u8868\u793a\u306f\u56de\u907f\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u5b9f\u884c\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u4e0b\u8a18\u306e\u901a\u308a\u3002<br>Hugging Face\u4e0a\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u5c11\u3057\u5909\u3048\u3066\u3001\u65e5\u672c\u8a9e\u3067\u56de\u7b54\u304c\u3082\u3089\u3048\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br>\u7121\u4e8b\u306b\u52d5\u3044\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import ctranslate2\nimport transformers\nimport torch\n\nmodel_name = \"Xwin-LM\/Xwin-LM-7B-V0.2\"\nct2_model = \".\/Xwin-LM-7B-V0.2\"\n\n# \u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u30fc\u3068\u30c8\u30fc\u30af\u30ca\u30a4\u30b6\u30fc\u306e\u6e96\u5099\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\ngenerator = ctranslate2.Generator(ct2_model, device=device)\ntokenizer = transformers.AutoTokenizer.from_pretrained(model_name, use_fast=False, legacy=False)\n\n(\n    prompt := \"A chat between a curious user and an artificial intelligence assistant. \"\n            \"The assistant gives helpful, detailed, and polite answers to the user's questions. \"\n            \"USER: Hello, can you help me? Please say Japanese.\"\n            \"ASSISTANT:\"\n)\n\ntokens = tokenizer.convert_ids_to_tokens(\n    tokenizer.encode(prompt, add_special_tokens=False, truncation=True, max_length=128) \n)\nresults = generator.generate_batch(\n    &#91;tokens],\n    sampling_topk=10,\n    sampling_temperature=0.7,\n    include_prompt_in_result=False,\n)\ntext = tokenizer.decode(results&#91;0].sequences_ids&#91;0])\nprint(text)<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<pre class=\"wp-block-preformatted\">\u3053\u3093\u306b\u3061\u306f\uff01\u3069\u306e\u3088\u3046\u306a\u304a\u624b\u4f1d\u3044\u304c\u3067\u304d\u307e\u3059\u304b\uff1f\u65e5\u672c\u8a9e\u3067\u304a\u8a71\u3057\u304c\u3067\u304d\u307e\u3059\u306e\u3067\u3001\u3069\u3093\u306a\u8cea\u554f\u3084\u76f8\u8ac7\u304c\u3042\u3063\u3066\u3082\u304a\u6c17\u8efd\u306b\u304a\u805e\u304b\u305b\u304f\u3060\u3055\u3044\u3002\n\n(Konnichiwa! What kind of help can I give you? I can speak Japanese, so feel free to ask any questions or share your concerns. )<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<\/blockquote>\n\n\n\n<p>\u5099\u5fd8\u9332\u306e\u610f\u5473\u5408\u3044\u5f37\u304f\u3001\u77ed\u3044\u3067\u3059\u304c\u8f09\u305b\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>Ctranslate2\u306e\u304a\u9670\u3067\u3001\u69d8\u3005\u306a\u30e2\u30c7\u30eb\u3092GPU\u306a\u3057\u306e\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u304a\u8a66\u3057\u3067\u4f7f\u3048\u308b\u306e\u306f\u3001\u5927\u5909\u52a9\u304b\u308a\u307e\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2023\u5e749\u6708\u306bOpenAI\u306e\u751f\u6210AI\u300cGPT-4\u300d\u3092\u4e0a\u56de\u308b\u6027\u80fd\u3092\u3046\u305f\u3063\u3066\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305fXwin-LM\u3002\u4e2d\u56fd\u79d1\u5b66\u9662\u3084\u6e05\u83ef\u5927\u5b66\u306e\u7814\u7a76\u8005\u3089\u304c\u958b\u767a\u3057\u305f\u3088\u3046\u3067\u3059\u3002\u30ed\u30b4\u683c\u597d\u3088\u3057\u3002 GitHub\u3001Hugging Face\u4e0a\u3067\u516c\u958b\u3055\u308c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":{"0":"post-1788","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-ai"},"_links":{"self":[{"href":"https:\/\/fukugyouhistory.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/1788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fukugyouhistory.tokyo\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fukugyouhistory.tokyo\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fukugyouhistory.tokyo\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fukugyouhistory.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1788"}],"version-history":[{"count":7,"href":"https:\/\/fukugyouhistory.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/1788\/revisions"}],"predecessor-version":[{"id":1805,"href":"https:\/\/fukugyouhistory.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/1788\/revisions\/1805"}],"wp:attachment":[{"href":"https:\/\/fukugyouhistory.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fukugyouhistory.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fukugyouhistory.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}