Skip to content

Commit

Permalink
docs: update output
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 23, 2023
1 parent d22ed38 commit 583a00d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 23 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ fun createTicketOrder(@RequestBody ticketOrder: TicketOrder): String {

现在的版本不行了:https://pytorch.org/get-started/locally/


## 本文相关资源

AI 生成图片:
Expand Down
86 changes: 64 additions & 22 deletions codeai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"outputs": [
{
"name": "stderr",
Expand All @@ -96,26 +96,17 @@
"name": "stdout",
"output_type": "stream",
"text": [
"fun hello_world() {\n",
" return \"Hello, World!\"\n",
" }\n",
" \"\"\"\n",
" )\n",
" result = script.run_cell(\n",
" \"\"\"\n",
" import os\n",
" import sys\n",
" import tempfile\n",
" import shutil\n",
" import tempfile\n",
" import unittest\n",
" import unittest.mock\n",
" import unittest.mock\n",
" import unittest.mock\n",
" import unittest.mock\n",
" import unittest.mock\n",
" import unittest.mock\n",
" import unittest.mock\n"
"def hello_world() {\n",
" return \"Hello World!\"\n",
"\n",
"def hello_world_with_params(name, age, gender):\n",
" return f\"Hello {name} you are {age} years old and you are {gender}.\"\n",
"\n",
"def hello_world_with_params_and_return(name, age, gender):\n",
" return f\"Hello {name} you are {age} years old and you are {gender}.\"\n",
"\n",
"def hello_world_with_params_and_return_and_return(name, age, gender):\n",
" return f\"Hello\n"
]
}
],
Expand All @@ -133,7 +124,58 @@
"tokenizer = AutoTokenizer.from_pretrained(\"/Volumes/game/ai-research/codegen-350M-mono\")\n",
"model = AutoModelForCausalLM.from_pretrained(\"/Volumes/game/ai-research/codegen-350M-mono\")\n",
"\n",
"text = \"fun hello_world() {\"\n",
"text = \"def hello_world() {\"\n",
"input_ids = tokenizer(text, return_tensors=\"pt\").input_ids\n",
"\n",
"generated_ids = model.generate(input_ids, max_length=128)\n",
"print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 3,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.\n",
"Setting `pad_token_id` to `eos_token_id`:50256 for open-end generation.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"def hello_world() {\n",
" return \"Hello, World!\";\n",
"}\n",
"\n",
"\"\"\"\n",
"\n",
"# The function name must be the same as the function definition\n",
"# The function body must be indented\n",
"# The function name must be followed by a colon (:)\n",
"# The function body must be indented\n",
"# The function name must be followed by a colon (:)\n",
"# The function body must be indented\n",
"# The function name must be followed by a colon (:)\n",
"# The function body must be indented\n",
"# The function name must be followed by a colon (:)\n",
"#\n"
]
}
],
"source": [
"from transformers import AutoTokenizer, AutoModelForCausalLM\n",
"\n",
"tokenizer = AutoTokenizer.from_pretrained(\"/Volumes/game/ai-research/codegen-2B-mono\")\n",
"model = AutoModelForCausalLM.from_pretrained(\"/Volumes/game/ai-research/codegen-2B-mono\")\n",
"\n",
"text = \"def hello_world() {\"\n",
"input_ids = tokenizer(text, return_tensors=\"pt\").input_ids\n",
"\n",
"generated_ids = model.generate(input_ids, max_length=128)\n",
Expand Down

0 comments on commit 583a00d

Please sign in to comment.