{"id":723,"date":"2022-12-01T08:53:23","date_gmt":"2022-12-01T08:53:23","guid":{"rendered":"https:\/\/doublelayer.eu\/vilab\/?p=723"},"modified":"2022-12-06T11:20:57","modified_gmt":"2022-12-06T11:20:57","slug":"playing-with-galactica","status":"publish","type":"post","link":"https:\/\/doublelayer.eu\/vilab\/2022\/12\/01\/playing-with-galactica\/","title":{"rendered":"Playing with Galactica"},"content":{"rendered":"<p>Installation of Galactica is as easy as:<\/p>\n<pre>conda create -n papers python=3.8<br>conda activate papers<br>pip install galai transformers accelerate<\/pre>\n\n\n<p>Now you can work with the simplest Galactica models (125m, 1.3b, 6.7b) using CPUs. Here is my script:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from transformers import AutoTokenizer, OPTForCausalLM\nimport sys\n\ntokenizer = AutoTokenizer.from_pretrained(\"facebook\/galactica-6.7b\")\ntokenizer.pad_token_id = 1\ntokenizer.padding_side = 'left'\ntokenizer.model_max_length = 200\nmodel = OPTForCausalLM.from_pretrained(\"facebook\/galactica-6.7b\", device_map=\"auto\")\n\n#input_text = '# Introduction \\n\\n The main idea of the paper \"Supervised hashing for image retrieval via image representation learning\" is'\n#input_text = \"# Review \\n\\n The main idea of the paper 'On the thickness of the double layer in ionic liquids'\"\n#input_text = \"# Review High entropy alloys in electrocatalysis\"\ninput_text = str(sys.argv[1])\ninput_ids = tokenizer(input_text, padding='max_length', return_tensors=\"pt\").input_ids\n\noutputs = model.generate(input_ids, max_new_tokens=200,\n                         do_sample=True,\n                         temperature=0.7,\n                         top_k=25,\n                         top_p=0.9,\n                         no_repeat_ngram_size=10,\n                         early_stopping=True)\nprint(tokenizer.decode(outputs[0]).lstrip('&lt;pad&gt;'))<\/pre>\n\n\n\n<p>Run it on your laptop as:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">python script.py \"YOUR QUERY\"<\/pre>\n\n\n\n<p>For example, let us check what Galactica know about HEA:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">python script.py \"High entropy alloys in catalysis \"<\/pre>\n\n\n\n<p>6.7b model will give:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>High entropy alloy catalysis (HEAC) is a new concept for catalytic applications. A series of HEAs with a similar chemical composition (CoCrFeNiMn) were prepared by arc-melting and characterized by X-ray diffraction (XRD), X-ray photoelectron spectroscopy (XPS), and high resolution transmission electron microscopy (HRTEM). The catalytic performance of the HEAs was tested in the CO oxidation reaction. The catalytic activity of the HEAs is compared with that of the pure metals and the HEA-supported Pt catalysts. The results show that the HEAs are active in the CO oxidation reaction, and that the activity is comparable to that of the Pt catalysts. The HEAs have a much lower activity than the pure metals. XPS and HRTEM results show that the HEAs have a different surface structure than the pure metals, which is probably the reason for the high catalytic activity of the HEA.<\/p>\n<cite>Galactica<\/cite><\/blockquote>\n\n\n\n<p>Also, let us review a paper by the CHEAC founders:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">python script.py '# Introduction \\n\\n The main idea of the paper \"Self-supported Pt\u2013CoO networks combining high specific activity with high surface area for oxygen reduction\" is'<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>&#8220;Self-supported Pt\u2013CoO networks combining high specific activity with high surface area for oxygen reduction&#8221; is to report the synthesis of highly porous self-supported electrocatalysts, which combine high surface area with high specific activity for the oxygen reduction reaction (ORR). The synthesis is based on a self-supported network of Pt doped CoO (Pt-CoO) nanoparticles, which are prepared by a two-step process. In the first step, Pt-doped Co\u2083O\u2084 (Pt-Co\u2083O\u2084) nanoparticles are formed via the thermal decomposition of Co- and Pt-oleate complexes, followed by the oxidation of Pt-Co\u2083O\u2084 to Pt-CoO at 550 \u00b0C. The resulting porous self-supported network consists of Pt-CoO nanoparticles with diameters of 4\u20135 nm and a high surface area of 130 m2\/g. The specific activity of the Pt-CoO network for the ORR is 2.6 times higher than that of the Pt\/C catalyst, and the mass activity is 2.<\/p>\n<cite>Galactica<\/cite><\/blockquote>\n\n\n\n<p>You can run the same code in Google Drive with colab.<\/p>\n\n\n\n<p>Here are some links:<\/p>\n\n\n\n<p>https:\/\/huggingface.co\/facebook\/galactica-125m<br>https:\/\/huggingface.co\/spaces\/morenolq\/galactica-base\/blob\/main\/app.py<br>https:\/\/github.com\/paperswithcode\/galai<br>https:\/\/github.com\/paperswithcode\/galai\/issues\/39<\/p>\n\n\n\n<p>P.S. https:\/\/chat.openai.com\/chat seems to be much cooler!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installation of Galactica is as easy as: conda create -n papers python=3.8conda activate paperspip install galai transformers accelerate Now you can work with the simplest Galactica models (125m, 1.3b, 6.7b) using CPUs. Here is my script: from transformers import AutoTokenizer, OPTForCausalLM import sys tokenizer = AutoTokenizer.from_pretrained(&#8220;facebook\/galactica-6.7b&#8221;) tokenizer.pad_token_id = 1 tokenizer.padding_side = &#8216;left&#8217; tokenizer.model_max_length = 200&hellip; <a class=\"read-more\" href=\"https:\/\/doublelayer.eu\/vilab\/2022\/12\/01\/playing-with-galactica\/\">Read More<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-723","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/comments?post=723"}],"version-history":[{"count":3,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/723\/revisions"}],"predecessor-version":[{"id":731,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/723\/revisions\/731"}],"wp:attachment":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/media?parent=723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/categories?post=723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/tags?post=723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}