import{S as di,i as ci,s as hi,e as a,k as c,w as T,t as r,M as ui,c as s,d as n,m as h,a as o,x as b,h as i,b as m,G as t,g as f,y as v,q as j,o as y,B as x,v as mi,L as at}from"../../chunks/vendor-hf-doc-builder.js";import{T as pi}from"../../chunks/Tip-hf-doc-builder.js";import{D as ye}from"../../chunks/Docstring-hf-doc-builder.js";import{C as xe}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as nt}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function fi(w){let p,k,u,_,$;return _=new xe({props:{code:`from transformers import GPTSanJapaneseTokenizer

tokenizer = GPTSanJapaneseTokenizer.from_pretrained("Tanrei/GPTSAN-japanese")
# You can confirm both \u6176\u5FDC and \u6176\u61C9 are encoded to 17750
tokenizer("\u543E\u8F29\u306F\u732B\u3067\u3042\u308B\u{1F42F}\u3002\u5B9F\u306F\u6176\u5FDC(\u6176\u61C9)\u5927\u5B66\u51FA\u8EAB")["input_ids"]

# Both \u6176\u5FDC and \u6176\u61C9 are decoded to \u6176\u5FDC
tokenizer.decode(tokenizer("\u543E\u8F29\u306F\u732B\u3067\u3042\u308B\u{1F42F}\u3002\u5B9F\u306F\u6176\u5FDC(\u6176\u61C9)\u5927\u5B66\u51FA\u8EAB")["input_ids"])`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPTSanJapaneseTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPTSanJapaneseTokenizer.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># You can confirm both \u6176\u5FDC and \u6176\u61C9 are encoded to 17750</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer(<span class="hljs-string">&quot;\u543E\u8F29\u306F\u732B\u3067\u3042\u308B\u{1F42F}\u3002\u5B9F\u306F\u6176\u5FDC(\u6176\u61C9)\u5927\u5B66\u51FA\u8EAB&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]
[<span class="hljs-number">35993</span>, <span class="hljs-number">35998</span>, <span class="hljs-number">34347</span>, <span class="hljs-number">31459</span>, <span class="hljs-number">30647</span>, <span class="hljs-number">31448</span>, <span class="hljs-number">25</span>, <span class="hljs-number">30659</span>, <span class="hljs-number">35729</span>, <span class="hljs-number">35676</span>, <span class="hljs-number">32417</span>, <span class="hljs-number">30647</span>, <span class="hljs-number">17750</span>, <span class="hljs-number">35589</span>, <span class="hljs-number">17750</span>, <span class="hljs-number">35590</span>, <span class="hljs-number">321</span>, <span class="hljs-number">1281</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Both \u6176\u5FDC and \u6176\u61C9 are decoded to \u6176\u5FDC</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(tokenizer(<span class="hljs-string">&quot;\u543E\u8F29\u306F\u732B\u3067\u3042\u308B\u{1F42F}\u3002\u5B9F\u306F\u6176\u5FDC(\u6176\u61C9)\u5927\u5B66\u51FA\u8EAB&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-string">&#x27;\u543E\u8F29\u306F\u732B\u3067\u3042\u308B\u{1F42F}\u3002\u5B9F\u306F\u6176\u5FDC(\u6176\u5FDC)\u5927\u5B66\u51FA\u8EAB&#x27;</span>`}}),{c(){p=a("p"),k=r("Example:"),u=c(),T(_.$$.fragment)},l(l){p=s(l,"P",{});var g=o(p);k=i(g,"Example:"),g.forEach(n),u=h(l),b(_.$$.fragment,l)},m(l,g){f(l,p,g),t(p,k),f(l,u,g),v(_,l,g),$=!0},p:at,i(l){$||(j(_.$$.fragment,l),$=!0)},o(l){y(_.$$.fragment,l),$=!1},d(l){l&&n(p),l&&n(u),x(_,l)}}}function _i(w){let p,k,u,_,$;return _=new xe({props:{code:`from transformers import GPTSanJapaneseTokenizer

tokenizer = GPTSanJapaneseTokenizer.from_pretrained("Tanrei/GPTSAN-japanese")
tokenizer("\u5B9F\u306F\u6176\u5FDC(\u6176\u61C9)\u5927\u5B66\u51FA\u8EAB", prefix_text="\u543E\u8F29\u306F\u732B\u3067\u3042\u308B\u{1F42F}\u3002")["input_ids"]

# Mask for Prefix-LM inputs
tokenizer("\u5B9F\u306F\u6176\u5FDC(\u6176\u61C9)\u5927\u5B66\u51FA\u8EAB", prefix_text="\u543E\u8F29\u306F\u732B\u3067\u3042\u308B\u{1F42F}\u3002")["token_type_ids"]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPTSanJapaneseTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPTSanJapaneseTokenizer.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer(<span class="hljs-string">&quot;\u5B9F\u306F\u6176\u5FDC(\u6176\u61C9)\u5927\u5B66\u51FA\u8EAB&quot;</span>, prefix_text=<span class="hljs-string">&quot;\u543E\u8F29\u306F\u732B\u3067\u3042\u308B\u{1F42F}\u3002&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]
[<span class="hljs-number">35993</span>, <span class="hljs-number">34347</span>, <span class="hljs-number">31459</span>, <span class="hljs-number">30647</span>, <span class="hljs-number">31448</span>, <span class="hljs-number">25</span>, <span class="hljs-number">30659</span>, <span class="hljs-number">35729</span>, <span class="hljs-number">35676</span>, <span class="hljs-number">35998</span>, <span class="hljs-number">32417</span>, <span class="hljs-number">30647</span>, <span class="hljs-number">17750</span>, <span class="hljs-number">35589</span>, <span class="hljs-number">17750</span>, <span class="hljs-number">35590</span>, <span class="hljs-number">321</span>, <span class="hljs-number">1281</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Mask for Prefix-LM inputs</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer(<span class="hljs-string">&quot;\u5B9F\u306F\u6176\u5FDC(\u6176\u61C9)\u5927\u5B66\u51FA\u8EAB&quot;</span>, prefix_text=<span class="hljs-string">&quot;\u543E\u8F29\u306F\u732B\u3067\u3042\u308B\u{1F42F}\u3002&quot;</span>)[<span class="hljs-string">&quot;token_type_ids&quot;</span>]
[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]`}}),{c(){p=a("p"),k=r("Example for Prefix-LM:"),u=c(),T(_.$$.fragment)},l(l){p=s(l,"P",{});var g=o(p);k=i(g,"Example for Prefix-LM:"),g.forEach(n),u=h(l),b(_.$$.fragment,l)},m(l,g){f(l,p,g),t(p,k),f(l,u,g),v(_,l,g),$=!0},p:at,i(l){$||(j(_.$$.fragment,l),$=!0)},o(l){y(_.$$.fragment,l),$=!1},d(l){l&&n(p),l&&n(u),x(_,l)}}}function gi(w){let p,k,u,_,$;return _=new xe({props:{code:`from transformers import GPTSanJapaneseTokenizer

tokenizer = GPTSanJapaneseTokenizer.from_pretrained("Tanrei/GPTSAN-japanese")
tokenizer([["\u6B66\u7530\u4FE1\u7384", "\u306F\u3001"], ["\u7E54\u7530\u4FE1\u9577", "\u306E\u914D\u4E0B\u306E\u3001"]], padding=True)["input_ids"]

# Mask for Prefix-LM inputs
tokenizer([["\u6B66\u7530\u4FE1\u7384", "\u306F\u3001"], ["\u7E54\u7530\u4FE1\u9577", "\u306E\u914D\u4E0B\u306E\u3001"]], padding=True)["token_type_ids"]

# Mask for padding
tokenizer([["\u6B66\u7530\u4FE1\u7384", "\u306F\u3001"], ["\u7E54\u7530\u4FE1\u9577", "\u306E\u914D\u4E0B\u306E\u3001"]], padding=True)["attention_mask"]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPTSanJapaneseTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPTSanJapaneseTokenizer.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer([[<span class="hljs-string">&quot;\u6B66\u7530\u4FE1\u7384&quot;</span>, <span class="hljs-string">&quot;\u306F\u3001&quot;</span>], [<span class="hljs-string">&quot;\u7E54\u7530\u4FE1\u9577&quot;</span>, <span class="hljs-string">&quot;\u306E\u914D\u4E0B\u306E\u3001&quot;</span>]], padding=<span class="hljs-literal">True</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]
[[<span class="hljs-number">35993</span>, <span class="hljs-number">8640</span>, <span class="hljs-number">25948</span>, <span class="hljs-number">35998</span>, <span class="hljs-number">30647</span>, <span class="hljs-number">35675</span>, <span class="hljs-number">35999</span>, <span class="hljs-number">35999</span>], [<span class="hljs-number">35993</span>, <span class="hljs-number">10382</span>, <span class="hljs-number">9868</span>, <span class="hljs-number">35998</span>, <span class="hljs-number">30646</span>, <span class="hljs-number">9459</span>, <span class="hljs-number">30646</span>, <span class="hljs-number">35675</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Mask for Prefix-LM inputs</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer([[<span class="hljs-string">&quot;\u6B66\u7530\u4FE1\u7384&quot;</span>, <span class="hljs-string">&quot;\u306F\u3001&quot;</span>], [<span class="hljs-string">&quot;\u7E54\u7530\u4FE1\u9577&quot;</span>, <span class="hljs-string">&quot;\u306E\u914D\u4E0B\u306E\u3001&quot;</span>]], padding=<span class="hljs-literal">True</span>)[<span class="hljs-string">&quot;token_type_ids&quot;</span>]
[[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>], [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Mask for padding</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer([[<span class="hljs-string">&quot;\u6B66\u7530\u4FE1\u7384&quot;</span>, <span class="hljs-string">&quot;\u306F\u3001&quot;</span>], [<span class="hljs-string">&quot;\u7E54\u7530\u4FE1\u9577&quot;</span>, <span class="hljs-string">&quot;\u306E\u914D\u4E0B\u306E\u3001&quot;</span>]], padding=<span class="hljs-literal">True</span>)[<span class="hljs-string">&quot;attention_mask&quot;</span>]
[[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>], [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]]`}}),{c(){p=a("p"),k=r("Example for batch encode:"),u=c(),T(_.$$.fragment)},l(l){p=s(l,"P",{});var g=o(p);k=i(g,"Example for batch encode:"),g.forEach(n),u=h(l),b(_.$$.fragment,l)},m(l,g){f(l,p,g),t(p,k),f(l,u,g),v(_,l,g),$=!0},p:at,i(l){$||(j(_.$$.fragment,l),$=!0)},o(l){y(_.$$.fragment,l),$=!1},d(l){l&&n(p),l&&n(u),x(_,l)}}}function ki(w){let p,k,u,_,$;return _=new xe({props:{code:`from transformers import GPTSanJapaneseTokenizer

tokenizer = GPTSanJapaneseTokenizer.from_pretrained("Tanrei/GPTSAN-japanese")
x_token = tokenizer("\uFF71\uFF72\uFF73\uFF74")
# input_ids:      | SOT | SEG | \uFF71 | \uFF72 | \uFF73 | \uFF74 |
# token_type_ids: | 1   | 0   | 0 | 0 | 0 | 0 |

x_token = tokenizer("", prefix_text="\uFF71\uFF72\uFF73\uFF74")
# input_ids:      | SOT | \uFF71 | \uFF72 | \uFF73 | \uFF74 | SEG |
# token_type_ids: | 1   | 1 | 1 | 1 | 1 | 0  |

x_token = tokenizer("\uFF73\uFF74", prefix_text="\uFF71\uFF72")
# input_ids:      | SOT | \uFF71 | \uFF72 | SEG | \uFF73 | \uFF74 |
# token_type_ids: | 1   | 1 | 1 | 0   | 0 | 0 |`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPTSanJapaneseTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPTSanJapaneseTokenizer.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>x_token = tokenizer(<span class="hljs-string">&quot;\uFF71\uFF72\uFF73\uFF74&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># input_ids:      | SOT | SEG | \uFF71 | \uFF72 | \uFF73 | \uFF74 |</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># token_type_ids: | 1   | 0   | 0 | 0 | 0 | 0 |</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>x_token = tokenizer(<span class="hljs-string">&quot;&quot;</span>, prefix_text=<span class="hljs-string">&quot;\uFF71\uFF72\uFF73\uFF74&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># input_ids:      | SOT | \uFF71 | \uFF72 | \uFF73 | \uFF74 | SEG |</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># token_type_ids: | 1   | 1 | 1 | 1 | 1 | 0  |</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>x_token = tokenizer(<span class="hljs-string">&quot;\uFF73\uFF74&quot;</span>, prefix_text=<span class="hljs-string">&quot;\uFF71\uFF72&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># input_ids:      | SOT | \uFF71 | \uFF72 | SEG | \uFF73 | \uFF74 |</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># token_type_ids: | 1   | 1 | 1 | 0   | 0 | 0 |</span>`}}),{c(){p=a("p"),k=r("Example:"),u=c(),T(_.$$.fragment)},l(l){p=s(l,"P",{});var g=o(p);k=i(g,"Example:"),g.forEach(n),u=h(l),b(_.$$.fragment,l)},m(l,g){f(l,p,g),t(p,k),f(l,u,g),v(_,l,g),$=!0},p:at,i(l){$||(j(_.$$.fragment,l),$=!0)},o(l){y(_.$$.fragment,l),$=!1},d(l){l&&n(p),l&&n(u),x(_,l)}}}function Ti(w){let p,k,u,_,$;return{c(){p=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a("code"),_=r("Module"),$=r(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){p=s(l,"P",{});var g=o(p);k=i(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s(g,"CODE",{});var M=o(u);_=i(M,"Module"),M.forEach(n),$=i(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(n)},m(l,g){f(l,p,g),t(p,k),t(p,u),t(u,_),t(p,$)},d(l){l&&n(p)}}}function bi(w){let p,k,u,_,$;return{c(){p=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),u=a("code"),_=r("Module"),$=r(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){p=s(l,"P",{});var g=o(p);k=i(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=s(g,"CODE",{});var M=o(u);_=i(M,"Module"),M.forEach(n),$=i(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(n)},m(l,g){f(l,p,g),t(p,k),t(p,u),t(u,_),t(p,$)},d(l){l&&n(p)}}}function vi(w){let p,k;return p=new xe({props:{code:`from transformers import AutoModel, AutoTokenizer, trainer_utils

device = "cuda"
model = AutoModel.from_pretrained("Tanrei/GPTSAN-japanese").to(device)
tokenizer = AutoTokenizer.from_pretrained("Tanrei/GPTSAN-japanese")
x_token = tokenizer("\u7E54\u7530\u4FE1\u9577\u306F\u3001", return_tensors="pt")
trainer_utils.set_seed(30)
input_ids = x_token.input_ids.to(device)
gen_token = model.generate(input_ids, max_new_tokens=50)
tokenizer.decode(gen_token[0])`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel, AutoTokenizer, trainer_utils

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModel.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>).to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>x_token = tokenizer(<span class="hljs-string">&quot;\u7E54\u7530\u4FE1\u9577\u306F\u3001&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>trainer_utils.set_seed(<span class="hljs-number">30</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = x_token.input_ids.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>gen_token = model.generate(input_ids, max_new_tokens=<span class="hljs-number">50</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(gen_token[<span class="hljs-number">0</span>])
<span class="hljs-string">&quot;\u7E54\u7530\u4FE1\u9577\u306F\u3001\u653F\u6CBB\u30FB\u8ECD\u4E8B\u306E\u4E2D\u67A2\u307E\u3067\u638C\u63E1\u3057\u305F\u653F\u6CBB\u5BB6\u3067\u3042\u308A\u3001\u65E5\u672C\u53F2\u4E0A\u985E\u3092\u898B\u306A\u3044\u9A5A\u7570\u7684\u306A\u8ECD\u4E8B\u4FB5\u653B\u3092\u7D9A\u3051...&quot;</span>`}}),{c(){T(p.$$.fragment)},l(u){b(p.$$.fragment,u)},m(u,_){v(p,u,_),k=!0},p:at,i(u){k||(j(p.$$.fragment,u),k=!0)},o(u){y(p.$$.fragment,u),k=!1},d(u){x(p,u)}}}function ji(w){let p,k;return p=new xe({props:{code:`from transformers import AutoModel, AutoTokenizer, trainer_utils

device = "cuda"
model = AutoModel.from_pretrained("Tanrei/GPTSAN-japanese").to(device)
tokenizer = AutoTokenizer.from_pretrained("Tanrei/GPTSAN-japanese")
x_token = tokenizer("", prefix_text="\u7E54\u7530\u4FE1\u9577\u306F\u3001", return_tensors="pt")
trainer_utils.set_seed(30)
input_ids = x_token.input_ids.to(device)
token_type_ids = x_token.token_type_ids.to(device)
gen_token = model.generate(input_ids, token_type_ids=token_type_ids, max_new_tokens=50)
tokenizer.decode(gen_token[0])`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel, AutoTokenizer, trainer_utils

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModel.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>).to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>x_token = tokenizer(<span class="hljs-string">&quot;&quot;</span>, prefix_text=<span class="hljs-string">&quot;\u7E54\u7530\u4FE1\u9577\u306F\u3001&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>trainer_utils.set_seed(<span class="hljs-number">30</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = x_token.input_ids.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>token_type_ids = x_token.token_type_ids.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>gen_token = model.generate(input_ids, token_type_ids=token_type_ids, max_new_tokens=<span class="hljs-number">50</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(gen_token[<span class="hljs-number">0</span>])
<span class="hljs-string">&quot;\u7E54\u7530\u4FE1\u9577\u306F\u3001\u653F\u6CBB\u30FB\u5916\u4EA4\u3067\u6570\u3005\u306E\u6226\u679C\u3092\u4E0A\u3052\u308B\u304C\u30011568\u5E74\u304B\u3089\u306F\u3001\u3044\u308F\u3086\u308B\u672C\u80FD\u5BFA\u306E\u5909\u3067\u7D30\u5DDD\u6674\u5143\u306B\u6697\u6BBA\u3055\u308C\u308B...&quot;</span>`}}),{c(){T(p.$$.fragment)},l(u){b(p.$$.fragment,u)},m(u,_){v(p,u,_),k=!0},p:at,i(u){k||(j(p.$$.fragment,u),k=!0)},o(u){y(p.$$.fragment,u),k=!1},d(u){x(p,u)}}}function yi(w){let p,k;return p=new xe({props:{code:`from transformers import AutoModel, AutoTokenizer, trainer_utils

device = "cuda"
model = AutoModel.from_pretrained("Tanrei/GPTSAN-japanese").to(device)
tokenizer = AutoTokenizer.from_pretrained("Tanrei/GPTSAN-japanese")
masked_sentence = "\u6B66\u7530\u4FE1\u7384\u306F\u3001<|inputmask|>\u6642\u4EE3\u30D5\u30A1\u30F3\u306A\u3089\u305C\u3072\u62BC\u3055\u3048<|inputmask|>\u304D\u305F\u3044\u540D\u5C06\u306E\u4E00\u4EBA\u3002"
x_token = tokenizer("", prefix_text=masked_sentence, return_tensors="pt")
trainer_utils.set_seed(30)
input_ids = x_token.input_ids.to(device)
token_type_ids = x_token.token_type_ids.to(device)
out_lm_token = model.generate(input_ids, token_type_ids=token_type_ids, max_new_tokens=50)
out_mlm_token = model(input_ids, token_type_ids=token_type_ids).logits.argmax(axis=-1)
tokenizer.decode(out_mlm_token[0])

tokenizer.decode(out_lm_token[0][input_ids.shape[1] :])`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel, AutoTokenizer, trainer_utils

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModel.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>).to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>masked_sentence = <span class="hljs-string">&quot;\u6B66\u7530\u4FE1\u7384\u306F\u3001&lt;|inputmask|&gt;\u6642\u4EE3\u30D5\u30A1\u30F3\u306A\u3089\u305C\u3072\u62BC\u3055\u3048&lt;|inputmask|&gt;\u304D\u305F\u3044\u540D\u5C06\u306E\u4E00\u4EBA\u3002&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>x_token = tokenizer(<span class="hljs-string">&quot;&quot;</span>, prefix_text=masked_sentence, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>trainer_utils.set_seed(<span class="hljs-number">30</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = x_token.input_ids.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>token_type_ids = x_token.token_type_ids.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>out_lm_token = model.generate(input_ids, token_type_ids=token_type_ids, max_new_tokens=<span class="hljs-number">50</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>out_mlm_token = model(input_ids, token_type_ids=token_type_ids).logits.argmax(axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(out_mlm_token[<span class="hljs-number">0</span>])
<span class="hljs-string">&quot;\u6B66\u7530\u4FE1\u7384\u306F\u3001\u6226\u56FD\u6642\u4EE3\u30D5\u30A1\u30F3\u306A\u3089\u305C\u3072\u62BC\u3055\u3048\u3066\u304A\u304D\u305F\u3044\u540D\u5C06\u306E\u4E00\u4EBA\u3002&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(out_lm_token[<span class="hljs-number">0</span>][input_ids.shape[<span class="hljs-number">1</span>] :])
<span class="hljs-string">&quot;\u6B66\u7530\u6C0F\u306E\u4E09\u4EE3\u306B\u6E21\u3063\u305F\u6B66\u7530\u5BB6\u306E\u3072\u3068\u308A\\n\u7532\u6590\u5E02\u306B\u4F4F\u3080\u3001\u65E5\u672C\u53F2\u4E0A\u6700\u5927\u306E\u6226\u56FD\u5927\u540D\u3002...&quot;</span>`}}),{c(){T(p.$$.fragment)},l(u){b(p.$$.fragment,u)},m(u,_){v(p,u,_),k=!0},p:at,i(u){k||(j(p.$$.fragment,u),k=!0)},o(u){y(p.$$.fragment,u),k=!1},d(u){x(p,u)}}}function xi(w){let p,k,u,_,$,l,g,M,Ta,qn,D,ne,Pt,$e,ba,St,va,En,st,ja,zn,ot,ya,An,W,ae,Gt,Pe,xa,wt,$a,Jn,se,Pa,qt,Sa,Ga,Mn,Se,Nn,V,oe,Et,Ge,wa,zt,qa,Cn,rt,Ea,On,B,re,At,we,za,Jt,Aa,Fn,S,Ja,Mt,Ma,Na,Nt,Ca,Oa,Ct,Fa,La,Ot,Ia,Da,Ft,Wa,Va,Lt,Ba,Ua,It,Ra,Ha,Dt,Ka,Qa,Ln,it,Ya,In,lt,Xa,Dn,pt,Za,Wn,dt,Wt,Vt,Bt,es,Vn,ct,Ut,Rt,Ht,ts,Bn,ht,Kt,Qt,Yt,ns,Un,U,ie,Xt,qe,as,Zt,ss,Rn,le,os,en,rs,is,Hn,R,pe,tn,Ee,ls,nn,ps,Kn,N,ze,ds,H,cs,ut,hs,us,Ae,ms,fs,_s,K,gs,mt,ks,Ts,ft,bs,vs,Qn,Q,de,an,Je,js,sn,ys,Yn,G,Me,xs,on,$s,Ps,Y,rn,Ss,Gs,ln,ws,qs,Ne,Es,Ce,zs,As,Js,ce,Ms,he,Ns,ue,Cs,me,Oe,Os,pn,Fs,Ls,C,Fe,Is,dn,Ds,Ws,fe,Xn,X,_e,cn,Le,Vs,hn,Bs,Zn,A,Ie,Us,un,Rs,Hs,De,Ks,We,Qs,Ys,Xs,Ve,Zs,Be,eo,to,no,O,Ue,ao,Z,so,_t,oo,ro,mn,io,lo,po,ge,ea,ee,ke,fn,Re,co,_n,ho,ta,J,He,uo,gn,mo,fo,Ke,_o,Qe,go,ko,To,Ye,bo,Xe,vo,jo,yo,P,Ze,xo,te,$o,gt,Po,So,kn,Go,wo,qo,Te,Eo,Tn,zo,Ao,bn,Jo,Mo,be,No,vn,Co,Oo,ve,Fo,jn,Lo,Io,je,na;return l=new I({}),$e=new I({}),Pe=new I({}),Se=new xe({props:{code:`from transformers import AutoModel, AutoTokenizer
import torch

tokenizer = AutoTokenizer.from_pretrained("Tanrei/GPTSAN-japanese")
model = AutoModel.from_pretrained("Tanrei/GPTSAN-japanese").cuda()
x_tok = tokenizer("\u306F\u3001", prefix_text="\u7E54\u7530\u4FE1\u9577", return_tensors="pt")
torch.manual_seed(0)
gen_tok = model.generate(x_tok.input_ids.cuda(), token_type_ids=x_tok.token_type_ids.cuda(), max_new_tokens=20)
tokenizer.decode(gen_tok[0])`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel, AutoTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModel.from_pretrained(<span class="hljs-string">&quot;Tanrei/GPTSAN-japanese&quot;</span>).cuda()
<span class="hljs-meta">&gt;&gt;&gt; </span>x_tok = tokenizer(<span class="hljs-string">&quot;\u306F\u3001&quot;</span>, prefix_text=<span class="hljs-string">&quot;\u7E54\u7530\u4FE1\u9577&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>torch.manual_seed(<span class="hljs-number">0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>gen_tok = model.generate(x_tok.input_ids.cuda(), token_type_ids=x_tok.token_type_ids.cuda(), max_new_tokens=<span class="hljs-number">20</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(gen_tok[<span class="hljs-number">0</span>])
<span class="hljs-string">&#x27;\u7E54\u7530\u4FE1\u9577\u306F\u30012004\u5E74\u306B\u300E\u6226\u56FDBASARA\u300F\u306E\u305F\u3081\u306B\u3001\u8C4A\u81E3\u79C0\u5409&#x27;</span>`}}),Ge=new I({}),we=new I({}),qe=new I({}),Ee=new I({}),ze=new ye({props:{name:"class transformers.GPTSanJapaneseConfig",anchor:"transformers.GPTSanJapaneseConfig",parameters:[{name:"vocab_size",val:" = 36000"},{name:"max_position_embeddings",val:" = 1280"},{name:"d_model",val:" = 1024"},{name:"d_ff",val:" = 8192"},{name:"d_ext",val:" = 4096"},{name:"d_spout",val:" = 128"},{name:"num_switch_layers",val:" = 10"},{name:"num_ext_layers",val:" = 0"},{name:"num_heads",val:" = 16"},{name:"num_experts",val:" = 16"},{name:"expert_capacity",val:" = 128"},{name:"dropout_rate",val:" = 0.0"},{name:"layer_norm_epsilon",val:" = 1e-05"},{name:"router_bias",val:" = False"},{name:"router_jitter_noise",val:" = 0.0"},{name:"router_dtype",val:" = 'float32'"},{name:"router_ignore_padding_tokens",val:" = False"},{name:"output_hidden_states",val:" = False"},{name:"output_attentions",val:" = False"},{name:"initializer_factor",val:" = 0.002"},{name:"output_router_logits",val:" = False"},{name:"use_cache",val:" = True"},{name:"separator_token_id",val:" = 35998"},{name:"pad_token_id",val:" = 35995"},{name:"eos_token_id",val:" = 35999"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GPTSanJapaneseConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 36000) &#x2014;
Vocabulary size of the GPTSANJapanese model. Defines the number of different tokens that can be represented
by the <code>inputs_ids</code> passed when calling <a href="/docs/transformers/v4.29.0/en/model_doc/gptsan-japanese#transformers.GPTSanJapaneseModel">GPTSanJapaneseModel</a>.`,name:"vocab_size"},{anchor:"transformers.GPTSanJapaneseConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 1280) &#x2014;
The maximum sequence length that this model might ever be used with. Defaults set this to 1280.`,name:"max_position_embeddings"},{anchor:"transformers.GPTSanJapaneseConfig.d_model",description:`<strong>d_model</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Size of the encoder layers and the pooler layer.`,name:"d_model"},{anchor:"transformers.GPTSanJapaneseConfig.d_ff",description:`<strong>d_ff</strong> (<code>int</code>, <em>optional</em>, defaults to 8192) &#x2014;
Size of the intermediate feed forward layer in each <code>SwitchTransformersBlock</code>.`,name:"d_ff"},{anchor:"transformers.GPTSanJapaneseConfig.d_ext",description:`<strong>d_ext</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Size of the intermediate feed forward layer in each Extra-layers.`,name:"d_ext"},{anchor:"transformers.GPTSanJapaneseConfig.d_spout",description:`<strong>d_spout</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Size of the <code>spout</code> vector.`,name:"d_spout"},{anchor:"transformers.GPTSanJapaneseConfig.num_switch_layers",description:`<strong>num_switch_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 10) &#x2014;
Number of layers in the Switch Transformer layer.`,name:"num_switch_layers"},{anchor:"transformers.GPTSanJapaneseConfig.num_ext_layers",description:`<strong>num_ext_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
Number of layers in the Extra-layers.`,name:"num_ext_layers"},{anchor:"transformers.GPTSanJapaneseConfig.num_heads",description:`<strong>num_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_heads"},{anchor:"transformers.GPTSanJapaneseConfig.num_experts",description:`<strong>num_experts</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Number of experts for each SwitchTransformer layer.`,name:"num_experts"},{anchor:"transformers.GPTSanJapaneseConfig.expert_capacity",description:`<strong>expert_capacity</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Number of tokens that can be stored in each expert. If set to 1, the model will behave like a regular
Transformer.`,name:"expert_capacity"},{anchor:"transformers.GPTSanJapaneseConfig.dropout_rate",description:`<strong>dropout_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The ratio for all dropout layers.`,name:"dropout_rate"},{anchor:"transformers.GPTSanJapaneseConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-5) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.GPTSanJapaneseConfig.router_bias",description:`<strong>router_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to add a bias to the router.`,name:"router_bias"},{anchor:"transformers.GPTSanJapaneseConfig.router_jitter_noise",description:`<strong>router_jitter_noise</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Amount of noise to add to the router. Set it to 0.0 during prediction or set small value (usually 1e-2)
during training.`,name:"router_jitter_noise"},{anchor:"transformers.GPTSanJapaneseConfig.router_dtype",description:`<strong>router_dtype</strong> (<code>str</code>, <em>optional</em>, default to <code>&quot;float32&quot;</code>) &#x2014;
The <code>dtype</code> used for the routers. It is preferable to keep the <code>dtype</code> to <code>&quot;float32&quot;</code> as specified in the
<em>selective precision</em> discussion in <a href="https://arxiv.org/abs/2101.03961" rel="nofollow">the paper</a>.`,name:"router_dtype"},{anchor:"transformers.GPTSanJapaneseConfig.router_ignore_padding_tokens",description:`<strong>router_ignore_padding_tokens</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to ignore padding tokens when routing.`,name:"router_ignore_padding_tokens"},{anchor:"transformers.GPTSanJapaneseConfig.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>, default to <code>False</code>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.GPTSanJapaneseConfig.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the attentions tensors of all attention layers.`,name:"output_attentions"},{anchor:"transformers.GPTSanJapaneseConfig.initializer_factor",description:`<strong>initializer_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 0.002) &#x2014;
A factor for initializing all weight matrices.`,name:"initializer_factor"},{anchor:"transformers.GPTSanJapaneseConfig.output_router_logits",description:`<strong>output_router_logits</strong> (<code>bool</code>, <em>optional</em>, default to <code>False</code>) &#x2014;
Whether or not to return the router logits of all experts.`,name:"output_router_logits"},{anchor:"transformers.GPTSanJapaneseConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models)`,name:"use_cache"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/gptsan_japanese/configuration_gptsan_japanese.py#L29"}}),Je=new I({}),Me=new ye({props:{name:"class transformers.GPTSanJapaneseTokenizer",anchor:"transformers.GPTSanJapaneseTokenizer",parameters:[{name:"vocab_file",val:""},{name:"emoji_file",val:""},{name:"unk_token",val:" = '<|nottoken|>'"},{name:"pad_token",val:" = '<|separator|>'"},{name:"bos_token",val:" = '<|startoftext|>'"},{name:"eos_token",val:" = '<|endoftext|>'"},{name:"sep_token",val:" = '<|segmenter|>'"},{name:"do_clean_text",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GPTSanJapaneseTokenizer.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
File containing the vocabulary.`,name:"vocab_file"},{anchor:"transformers.GPTSanJapaneseTokenizer.emoji_file",description:`<strong>emoji_file</strong> (<code>str</code>) &#x2014;
File containing the emoji.`,name:"emoji_file"},{anchor:"transformers.GPTSanJapaneseTokenizer.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;|nottoken|&gt;&quot;</code>) &#x2014;
The token used for unknown charactor`,name:"unk_token"},{anchor:"transformers.GPTSanJapaneseTokenizer.pad_token",description:`<strong>pad_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;|separator|&gt;&quot;</code>) &#x2014;
The token used for padding`,name:"pad_token"},{anchor:"transformers.GPTSanJapaneseTokenizer.bos_token",description:`<strong>bos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;|startoftext|&gt;&quot;&quot;</code>) &#x2014;
The beginning of sequence token.`,name:"bos_token"},{anchor:"transformers.GPTSanJapaneseTokenizer.eos_token",description:`<strong>eos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;|endoftext|&gt;&quot;</code>) &#x2014;
The end of sequence token.`,name:"eos_token"},{anchor:"transformers.GPTSanJapaneseTokenizer.sep_token",description:`<strong>sep_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;|segmenter|&gt;&quot;</code>) &#x2014;
A special token to separate token to prefix part and general input part.`,name:"sep_token"},{anchor:"transformers.GPTSanJapaneseTokenizer.do_clean_text",description:`<strong>do_clean_text</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to clean text for URL, EMAIL, TEL, Japanese DATE and Japanese PRICE.`,name:"do_clean_text"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/gptsan_japanese/tokenization_gptsan_japanese.py#L79"}}),ce=new nt({props:{anchor:"transformers.GPTSanJapaneseTokenizer.example",$$slots:{default:[fi]},$$scope:{ctx:w}}}),he=new nt({props:{anchor:"transformers.GPTSanJapaneseTokenizer.example-2",$$slots:{default:[_i]},$$scope:{ctx:w}}}),ue=new nt({props:{anchor:"transformers.GPTSanJapaneseTokenizer.example-3",$$slots:{default:[gi]},$$scope:{ctx:w}}}),Oe=new ye({props:{name:"convert_tokens_to_string",anchor:"transformers.GPTSanJapaneseTokenizer.convert_tokens_to_string",parameters:[{name:"tokens",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/gptsan_japanese/tokenization_gptsan_japanese.py#L223"}}),Fe=new ye({props:{name:"create_token_type_ids_from_sequences",anchor:"transformers.GPTSanJapaneseTokenizer.create_token_type_ids_from_sequences",parameters:[{name:"token_ids_0",val:": typing.List[int]"},{name:"token_ids_1",val:": typing.Optional[typing.List[int]] = None"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/gptsan_japanese/tokenization_gptsan_japanese.py#L304"}}),fe=new nt({props:{anchor:"transformers.GPTSanJapaneseTokenizer.create_token_type_ids_from_sequences.example",$$slots:{default:[ki]},$$scope:{ctx:w}}}),Le=new I({}),Ie=new ye({props:{name:"class transformers.GPTSanJapaneseModel",anchor:"transformers.GPTSanJapaneseModel",parameters:[{name:"config",val:": GPTSanJapaneseConfig"}],parametersDescription:[{anchor:"transformers.GPTSanJapaneseModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.29.0/en/model_doc/gptsan-japanese#transformers.GPTSanJapaneseConfig">GPTSanJapaneseConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/gptsan_japanese/modeling_gptsan_japanese.py#L865"}}),Ue=new ye({props:{name:"forward",anchor:"transformers.GPTSanJapaneseModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.FloatTensor] = None"},{name:"spout",val:": typing.Optional[torch.FloatTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = False"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"output_router_logits",val:": typing.Optional[bool] = None"},{name:"num_precontext",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.GPTSanJapaneseModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. GPTSAN-japanese is a model that generates sentence
continuations or predicts tokens at mask positions. Special tokens required for inputs to the model are
automatically appended.`,name:"input_ids"},{anchor:"transformers.GPTSanJapaneseModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPTSanJapaneseModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
An input that masks the Prefix part in the Prefix-LM input. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>prefix</strong> input,</li>
<li>0 for tokens that are <strong>not-prefix</strong> input.</li>
</ul>`,name:"token_type_ids"},{anchor:"transformers.GPTSanJapaneseModel.forward.spout",description:`<strong>spout</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, config.d_spout)</code>) &#x2014;
This vector is transformed through an 8-layer FFN and can be used instead of <code>past_key_values</code>.`,name:"spout"},{anchor:"transformers.GPTSanJapaneseModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.GPTSanJapaneseModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:`,name:"head_mask"},{anchor:"transformers.GPTSanJapaneseModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.GPTSanJapaneseModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.GPTSanJapaneseModel.forward.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. If <code>past_key_values</code> is used, optionally only the last <code>decoder_inputs_embeds</code> have to be
input (see <code>past_key_values</code>). This is useful if you want more control over how to convert
<code>decoder_input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"decoder_inputs_embeds"},{anchor:"transformers.GPTSanJapaneseModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.GPTSanJapaneseModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.GPTSanJapaneseModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.29.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPTSanJapaneseModel.forward.router_logits",description:`<strong>router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.add_router_probs=True</code>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, sequence_length, num_experts)</code>.
Router logits of the decoder model, useful to compute the auxiliary loss for Mixture of Experts models.`,name:"router_logits"},{anchor:"transformers.GPTSanJapaneseModel.forward.num_precontext",description:`<strong>num_precontext</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,1)</code>) &#x2014;
length of <code>hybrid</code> input tokens in the input. Tokens up to this length refer to both front and back like
BERT, tokens after that refer only to front like GPT. see also:
<a href="https://github.com/tanreinama/GPTSAN/blob/main/report/model.md" rel="nofollow">https://github.com/tanreinama/GPTSAN/blob/main/report/model.md</a>`,name:"num_precontext"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/gptsan_japanese/modeling_gptsan_japanese.py#L899",returnDescription:`
<p><code>MoEModelOutputWithPastAndCrossAttentions</code> or <code>tuple</code> if <code>return_dict</code> returns
MoEModelOutputWithPastAndCrossAttentions insted of tuple</p>
`}}),ge=new pi({props:{$$slots:{default:[Ti]},$$scope:{ctx:w}}}),Re=new I({}),He=new ye({props:{name:"class transformers.GPTSanJapaneseForConditionalGeneration",anchor:"transformers.GPTSanJapaneseForConditionalGeneration",parameters:[{name:"config",val:": GPTSanJapaneseConfig"}],parametersDescription:[{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.29.0/en/model_doc/gptsan-japanese#transformers.GPTSanJapaneseConfig">GPTSanJapaneseConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/gptsan_japanese/modeling_gptsan_japanese.py#L1110"}}),Ze=new ye({props:{name:"forward",anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.FloatTensor] = None"},{name:"spout",val:": typing.Optional[torch.FloatTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = False"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"output_router_logits",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"}],parametersDescription:[{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. GPTSAN-japanese is a model that generates sentence
continuations or predicts tokens at mask positions. Special tokens required for inputs to the model are
automatically appended.`,name:"input_ids"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
An input that masks the Prefix part in the Prefix-LM input. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>prefix</strong> input,</li>
<li>0 for tokens that are <strong>not-prefix</strong> input.</li>
</ul>`,name:"token_type_ids"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.spout",description:`<strong>spout</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, config.d_spout)</code>) &#x2014;
This vector is transformed through an 8-layer FFN and can be used instead of <code>past_key_values</code>.`,name:"spout"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:`,name:"head_mask"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. If <code>past_key_values</code> is used, optionally only the last <code>decoder_inputs_embeds</code> have to be
input (see <code>past_key_values</code>). This is useful if you want more control over how to convert
<code>decoder_input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"decoder_inputs_embeds"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.29.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.router_logits",description:`<strong>router_logits</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_router_logits=True</code> is passed or when <code>config.add_router_probs=True</code>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, sequence_length, num_experts)</code>.
Router logits of the decoder model, useful to compute the auxiliary loss for Mixture of Experts models.`,name:"router_logits"},{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification loss. Indices should be in <code>[-100, 0, ..., config.vocab_size - 1]</code>. All labels set to <code>-100</code> are ignored (masked), the loss is only computed for
labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.29.0/src/transformers/models/gptsan_japanese/modeling_gptsan_japanese.py#L1121",returnDescription:`
<p><code>MoECausalLMOutputWithPast</code> or <code>tuple</code> if <code>return_dict</code> returns MoECausalLMOutputWithPast insted of tuple</p>
`}}),Te=new pi({props:{$$slots:{default:[bi]},$$scope:{ctx:w}}}),be=new nt({props:{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.example",$$slots:{default:[vi]},$$scope:{ctx:w}}}),ve=new nt({props:{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.example-2",$$slots:{default:[ji]},$$scope:{ctx:w}}}),je=new nt({props:{anchor:"transformers.GPTSanJapaneseForConditionalGeneration.forward.example-3",$$slots:{default:[yi]},$$scope:{ctx:w}}}),{c(){p=a("meta"),k=c(),u=a("h1"),_=a("a"),$=a("span"),T(l.$$.fragment),g=c(),M=a("span"),Ta=r("GPTSAN-japanese"),qn=c(),D=a("h2"),ne=a("a"),Pt=a("span"),T($e.$$.fragment),ba=c(),St=a("span"),va=r("Overview"),En=c(),st=a("p"),ja=r("The GPTSAN-japanese model was released in the repository by Toshiyuki Sakamoto (tanreinama)."),zn=c(),ot=a("p"),ya=r(`GPTSAN is a Japanese language model using Switch Transformer. It has the same structure as the model introduced as Prefix LM
in the T5 paper, and support both Text Generation and Masked Language Modeling tasks. These basic tasks similarly can
fine-tune for translation or summarization.`),An=c(),W=a("h3"),ae=a("a"),Gt=a("span"),T(Pe.$$.fragment),xa=c(),wt=a("span"),$a=r("Generation"),Jn=c(),se=a("p"),Pa=r("The "),qt=a("code"),Sa=r("generate()"),Ga=r(" method can be used to generate text using GPTSAN-Japanese model."),Mn=c(),T(Se.$$.fragment),Nn=c(),V=a("h2"),oe=a("a"),Et=a("span"),T(Ge.$$.fragment),wa=c(),zt=a("span"),qa=r("GPTSAN Features"),Cn=c(),rt=a("p"),Ea=r(`GPTSAN has some unique features. It has a model structure of Prefix-LM. It works as a shifted Masked Language Model for Prefix Input tokens. Un-prefixed inputs behave like normal generative models.
The Spout vector is a GPTSAN specific input. Spout is pre-trained with random inputs, but you can specify a class of text or an arbitrary vector during fine-tuning. This allows you to indicate the tendency of the generated text.
GPTSAN has a sparse Feed Forward based on Switch-Transformer. You can also add other layers and train them partially. See the original GPTSAN repository for details.`),On=c(),B=a("h3"),re=a("a"),At=a("span"),T(we.$$.fragment),za=c(),Jt=a("span"),Aa=r("Prefix-LM Model"),Fn=c(),S=a("p"),Ja=r("GPTSAN has the structure of the model named Prefix-LM in the "),Mt=a("code"),Ma=r("T5"),Na=r(" paper. (The original GPTSAN repository calls it "),Nt=a("code"),Ca=r("hybrid"),Oa=r(`)
In GPTSAN, the `),Ct=a("code"),Fa=r("Prefix"),La=r(` part of Prefix-LM, that is, the input position that can be referenced by both tokens, can be specified with any length.
Arbitrary lengths can also be specified differently for each batch.
This length applies to the text entered in `),Ot=a("code"),Ia=r("prefix_text"),Da=r(` for the tokenizer.
The tokenizer returns the mask of the `),Ft=a("code"),Wa=r("Prefix"),Va=r(" part of Prefix-LM as "),Lt=a("code"),Ba=r("token_type_ids"),Ua=r(`.
The model treats the part where `),It=a("code"),Ra=r("token_type_ids"),Ha=r(" is 1 as a "),Dt=a("code"),Ka=r("Prefix"),Qa=r(" part, that is, the input can refer to both tokens before and after."),Ln=c(),it=a("p"),Ya=r("Tips:"),In=c(),lt=a("p"),Xa=r(`Specifying the Prefix part is done with a mask passed to self-attention.
When token_type_ids=None or all zero, it is equivalent to regular causal mask`),Dn=c(),pt=a("p"),Za=r("for example:"),Wn=c(),dt=a("blockquote"),Wt=a("blockquote"),Vt=a("blockquote"),Bt=a("p"),es=r(`x_token = tokenizer(\u201C\uFF71\uFF72\uFF73\uFF74\u201D)
input_ids:      | SOT | SEG | \uFF71 | \uFF72 | \uFF73 | \uFF74 |
token_type_ids: | 1   | 0   | 0 | 0 | 0 | 0 |
prefix_lm_mask:
SOT | 1 0 0 0 0 0 |
SEG | 1 1 0 0 0 0 |
\uFF71   | 1 1 1 0 0 0 |
\uFF72   | 1 1 1 1 0 0 |
\uFF73   | 1 1 1 1 1 0 |
\uFF74   | 1 1 1 1 1 1 |`),Vn=c(),ct=a("blockquote"),Ut=a("blockquote"),Rt=a("blockquote"),Ht=a("p"),ts=r(`x_token = tokenizer("", prefix_text=\u201C\uFF71\uFF72\uFF73\uFF74\u201D)
input_ids:      | SOT | \uFF71 | \uFF72 | \uFF73 | \uFF74 | SEG |
token_type_ids: | 1   | 1 | 1 | 1 | 1 | 0  |
prefix_lm_mask:
SOT | 1 1 1 1 1 0 |
\uFF71   | 1 1 1 1 1 0 |
\uFF72   | 1 1 1 1 1 0 |
\uFF73   | 1 1 1 1 1 0 |
\uFF74   | 1 1 1 1 1 0 |
SEG | 1 1 1 1 1 1 |`),Bn=c(),ht=a("blockquote"),Kt=a("blockquote"),Qt=a("blockquote"),Yt=a("p"),ns=r(`x_token = tokenizer(\u201C\uFF73\uFF74\u201D, prefix_text=\u201C\uFF71\uFF72\u201D)
input_ids:      | SOT | \uFF71 | \uFF72 | SEG | \uFF73 | \uFF74 |
token_type_ids: | 1   | 1 | 1 | 0   | 0 | 0 |
prefix_lm_mask:
SOT | 1 1 1 0 0 0 |
\uFF71   | 1 1 1 0 0 0 |
\uFF72   | 1 1 1 0 0 0 |
SEG | 1 1 1 1 0 0 |
\uFF73   | 1 1 1 1 1 0 |
\uFF74   | 1 1 1 1 1 1 |`),Un=c(),U=a("h3"),ie=a("a"),Xt=a("span"),T(qe.$$.fragment),as=c(),Zt=a("span"),ss=r("Spout Vector"),Rn=c(),le=a("p"),os=r(`A Spout Vector is a special vector for controlling text generation.
This vector is treated as the first embedding in self-attention to bring extraneous attention to the generated tokens.
In the pre-trained model published from `),en=a("code"),rs=r("Tanrei/GPTSAN-japanese"),is=r(`, the Spout Vector is a 128-dimensional vector that passes through 8 fully connected layers in the model and is projected into the space acting as external attention.
The Spout Vector projected by the fully connected layer is split to be passed to all self-attentions.`),Hn=c(),R=a("h2"),pe=a("a"),tn=a("span"),T(Ee.$$.fragment),ls=c(),nn=a("span"),ps=r("GPTSanJapaneseConfig"),Kn=c(),N=a("div"),T(ze.$$.fragment),ds=c(),H=a("p"),cs=r("This is the configuration class to store the configuration of a "),ut=a("a"),hs=r("GPTSanJapaneseModel"),us=r(`. It is used to instantiate
a GPTSANJapanese model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the GPTSANJapanese
`),Ae=a("a"),ms=r("Tanrei/GPTSAN-japanese"),fs=r(" architecture."),_s=c(),K=a("p"),gs=r("Configuration objects inherit from "),mt=a("a"),ks=r("PretrainedConfig"),Ts=r(` and can be used to control the model outputs. Read the
documentation from `),ft=a("a"),bs=r("PretrainedConfig"),vs=r(" for more information."),Qn=c(),Q=a("h2"),de=a("a"),an=a("span"),T(Je.$$.fragment),js=c(),sn=a("span"),ys=r("GPTSanJapaneseTokenizer"),Yn=c(),G=a("div"),T(Me.$$.fragment),xs=c(),on=a("p"),$s=r("This tokenizer is based on GPTNeoXJapaneseTokenizer and has the following modifications"),Ps=c(),Y=a("ul"),rn=a("li"),Ss=r("Decoding byte0~byte255 tokens correctly"),Gs=c(),ln=a("li"),ws=r("Added bagofword token handling"),qs=c(),Ne=a("li"),Es=r(`Return token_type_ids for Prefix-LM model
The bagofword token represents a repetition of the previous token and is converted to 3 consecutive tokens when
decoding In addition, the original Japanese special Sub-Word-Encoding has been released in this repository
(`),Ce=a("a"),zs=r("https://github.com/tanreinama/Japanese-BPEEncoder_V2"),As=r(`). The token_type_ids is a mask indicating the prefix input
position of the Prefix-LM model. To specify a prefix position, specify a prefix input for prefix_text, or specify a
sentence of the prefix part and the part after it as a text pair of batch input.`),Js=c(),T(ce.$$.fragment),Ms=c(),T(he.$$.fragment),Ns=c(),T(ue.$$.fragment),Cs=c(),me=a("div"),T(Oe.$$.fragment),Os=c(),pn=a("p"),Fs=r("Converts a sequence of tokens (string) in a single string."),Ls=c(),C=a("div"),T(Fe.$$.fragment),Is=c(),dn=a("p"),Ds=r(`The tokenizer returns token_type_ids as separators between the Prefix part and the rest.
token_type_ids is 1 for the Prefix part and 0 for the rest of the token.`),Ws=c(),T(fe.$$.fragment),Xn=c(),X=a("h2"),_e=a("a"),cn=a("span"),T(Le.$$.fragment),Vs=c(),hn=a("span"),Bs=r("GPTSanJapaneseModel"),Zn=c(),A=a("div"),T(Ie.$$.fragment),Us=c(),un=a("p"),Rs=r("The bare GPTSAN-japanese Model transformer outputting raw hidden-states without any specific head on top."),Hs=c(),De=a("p"),Ks=r("The "),We=a("a"),Qs=r("GPTSAN-japanese"),Ys=r(` model was proposed in General-purpose Swich transformer
based Japanese language model`),Xs=c(),Ve=a("p"),Zs=r("This model is also a PyTorch "),Be=a("a"),eo=r("torch.nn.Module"),to=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),no=c(),O=a("div"),T(Ue.$$.fragment),ao=c(),Z=a("p"),so=r("The "),_t=a("a"),oo=r("GPTSanJapaneseModel"),ro=r(" forward method, overrides the "),mn=a("code"),io=r("__call__"),lo=r(" special method."),po=c(),T(ge.$$.fragment),ea=c(),ee=a("h2"),ke=a("a"),fn=a("span"),T(Re.$$.fragment),co=c(),_n=a("span"),ho=r("GPTSanJapaneseForConditionalGeneration"),ta=c(),J=a("div"),T(He.$$.fragment),uo=c(),gn=a("p"),mo=r("The bare GPTSAN-japanese Model with a language modeling head."),fo=c(),Ke=a("p"),_o=r("The "),Qe=a("a"),go=r("GPTSAN-japanese"),ko=r(` model was proposed in General-purpose Swich transformer
based Japanese language model`),To=c(),Ye=a("p"),bo=r("This model is also a PyTorch "),Xe=a("a"),vo=r("torch.nn.Module"),jo=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),yo=c(),P=a("div"),T(Ze.$$.fragment),xo=c(),te=a("p"),$o=r("The "),gt=a("a"),Po=r("GPTSanJapaneseForConditionalGeneration"),So=r(" forward method, overrides the "),kn=a("code"),Go=r("__call__"),wo=r(" special method."),qo=c(),T(Te.$$.fragment),Eo=c(),Tn=a("p"),zo=r("Example:"),Ao=c(),bn=a("p"),Jo=r("Text Generation with regular LM Model"),Mo=c(),T(be.$$.fragment),No=c(),vn=a("p"),Co=r("Text Generation with Prefix-LM Model"),Oo=c(),T(ve.$$.fragment),Fo=c(),jn=a("p"),Lo=r("Simultaneously Text Generation And Masked Language Model"),Io=c(),T(je.$$.fragment),this.h()},l(e){const d=ui('[data-svelte="svelte-1phssyn"]',document.head);p=s(d,"META",{name:!0,content:!0}),d.forEach(n),k=h(e),u=s(e,"H1",{class:!0});var et=o(u);_=s(et,"A",{id:!0,class:!0,href:!0});var yn=o(_);$=s(yn,"SPAN",{});var xn=o($);b(l.$$.fragment,xn),xn.forEach(n),yn.forEach(n),g=h(et),M=s(et,"SPAN",{});var $n=o(M);Ta=i($n,"GPTSAN-japanese"),$n.forEach(n),et.forEach(n),qn=h(e),D=s(e,"H2",{class:!0});var tt=o(D);ne=s(tt,"A",{id:!0,class:!0,href:!0});var Pn=o(ne);Pt=s(Pn,"SPAN",{});var Sn=o(Pt);b($e.$$.fragment,Sn),Sn.forEach(n),Pn.forEach(n),ba=h(tt),St=s(tt,"SPAN",{});var Gn=o(St);va=i(Gn,"Overview"),Gn.forEach(n),tt.forEach(n),En=h(e),st=s(e,"P",{});var wn=o(st);ja=i(wn,"The GPTSAN-japanese model was released in the repository by Toshiyuki Sakamoto (tanreinama)."),wn.forEach(n),zn=h(e),ot=s(e,"P",{});var Do=o(ot);ya=i(Do,`GPTSAN is a Japanese language model using Switch Transformer. It has the same structure as the model introduced as Prefix LM
in the T5 paper, and support both Text Generation and Masked Language Modeling tasks. These basic tasks similarly can
fine-tune for translation or summarization.`),Do.forEach(n),An=h(e),W=s(e,"H3",{class:!0});var aa=o(W);ae=s(aa,"A",{id:!0,class:!0,href:!0});var Wo=o(ae);Gt=s(Wo,"SPAN",{});var Vo=o(Gt);b(Pe.$$.fragment,Vo),Vo.forEach(n),Wo.forEach(n),xa=h(aa),wt=s(aa,"SPAN",{});var Bo=o(wt);$a=i(Bo,"Generation"),Bo.forEach(n),aa.forEach(n),Jn=h(e),se=s(e,"P",{});var sa=o(se);Pa=i(sa,"The "),qt=s(sa,"CODE",{});var Uo=o(qt);Sa=i(Uo,"generate()"),Uo.forEach(n),Ga=i(sa," method can be used to generate text using GPTSAN-Japanese model."),sa.forEach(n),Mn=h(e),b(Se.$$.fragment,e),Nn=h(e),V=s(e,"H2",{class:!0});var oa=o(V);oe=s(oa,"A",{id:!0,class:!0,href:!0});var Ro=o(oe);Et=s(Ro,"SPAN",{});var Ho=o(Et);b(Ge.$$.fragment,Ho),Ho.forEach(n),Ro.forEach(n),wa=h(oa),zt=s(oa,"SPAN",{});var Ko=o(zt);qa=i(Ko,"GPTSAN Features"),Ko.forEach(n),oa.forEach(n),Cn=h(e),rt=s(e,"P",{});var Qo=o(rt);Ea=i(Qo,`GPTSAN has some unique features. It has a model structure of Prefix-LM. It works as a shifted Masked Language Model for Prefix Input tokens. Un-prefixed inputs behave like normal generative models.
The Spout vector is a GPTSAN specific input. Spout is pre-trained with random inputs, but you can specify a class of text or an arbitrary vector during fine-tuning. This allows you to indicate the tendency of the generated text.
GPTSAN has a sparse Feed Forward based on Switch-Transformer. You can also add other layers and train them partially. See the original GPTSAN repository for details.`),Qo.forEach(n),On=h(e),B=s(e,"H3",{class:!0});var ra=o(B);re=s(ra,"A",{id:!0,class:!0,href:!0});var Yo=o(re);At=s(Yo,"SPAN",{});var Xo=o(At);b(we.$$.fragment,Xo),Xo.forEach(n),Yo.forEach(n),za=h(ra),Jt=s(ra,"SPAN",{});var Zo=o(Jt);Aa=i(Zo,"Prefix-LM Model"),Zo.forEach(n),ra.forEach(n),Fn=h(e),S=s(e,"P",{});var E=o(S);Ja=i(E,"GPTSAN has the structure of the model named Prefix-LM in the "),Mt=s(E,"CODE",{});var er=o(Mt);Ma=i(er,"T5"),er.forEach(n),Na=i(E," paper. (The original GPTSAN repository calls it "),Nt=s(E,"CODE",{});var tr=o(Nt);Ca=i(tr,"hybrid"),tr.forEach(n),Oa=i(E,`)
In GPTSAN, the `),Ct=s(E,"CODE",{});var nr=o(Ct);Fa=i(nr,"Prefix"),nr.forEach(n),La=i(E,` part of Prefix-LM, that is, the input position that can be referenced by both tokens, can be specified with any length.
Arbitrary lengths can also be specified differently for each batch.
This length applies to the text entered in `),Ot=s(E,"CODE",{});var ar=o(Ot);Ia=i(ar,"prefix_text"),ar.forEach(n),Da=i(E,` for the tokenizer.
The tokenizer returns the mask of the `),Ft=s(E,"CODE",{});var sr=o(Ft);Wa=i(sr,"Prefix"),sr.forEach(n),Va=i(E," part of Prefix-LM as "),Lt=s(E,"CODE",{});var or=o(Lt);Ba=i(or,"token_type_ids"),or.forEach(n),Ua=i(E,`.
The model treats the part where `),It=s(E,"CODE",{});var rr=o(It);Ra=i(rr,"token_type_ids"),rr.forEach(n),Ha=i(E," is 1 as a "),Dt=s(E,"CODE",{});var ir=o(Dt);Ka=i(ir,"Prefix"),ir.forEach(n),Qa=i(E," part, that is, the input can refer to both tokens before and after."),E.forEach(n),Ln=h(e),it=s(e,"P",{});var lr=o(it);Ya=i(lr,"Tips:"),lr.forEach(n),In=h(e),lt=s(e,"P",{});var pr=o(lt);Xa=i(pr,`Specifying the Prefix part is done with a mask passed to self-attention.
When token_type_ids=None or all zero, it is equivalent to regular causal mask`),pr.forEach(n),Dn=h(e),pt=s(e,"P",{});var dr=o(pt);Za=i(dr,"for example:"),dr.forEach(n),Wn=h(e),dt=s(e,"BLOCKQUOTE",{});var cr=o(dt);Wt=s(cr,"BLOCKQUOTE",{});var hr=o(Wt);Vt=s(hr,"BLOCKQUOTE",{});var ur=o(Vt);Bt=s(ur,"P",{});var mr=o(Bt);es=i(mr,`x_token = tokenizer(\u201C\uFF71\uFF72\uFF73\uFF74\u201D)
input_ids:      | SOT | SEG | \uFF71 | \uFF72 | \uFF73 | \uFF74 |
token_type_ids: | 1   | 0   | 0 | 0 | 0 | 0 |
prefix_lm_mask:
SOT | 1 0 0 0 0 0 |
SEG | 1 1 0 0 0 0 |
\uFF71   | 1 1 1 0 0 0 |
\uFF72   | 1 1 1 1 0 0 |
\uFF73   | 1 1 1 1 1 0 |
\uFF74   | 1 1 1 1 1 1 |`),mr.forEach(n),ur.forEach(n),hr.forEach(n),cr.forEach(n),Vn=h(e),ct=s(e,"BLOCKQUOTE",{});var fr=o(ct);Ut=s(fr,"BLOCKQUOTE",{});var _r=o(Ut);Rt=s(_r,"BLOCKQUOTE",{});var gr=o(Rt);Ht=s(gr,"P",{});var kr=o(Ht);ts=i(kr,`x_token = tokenizer("", prefix_text=\u201C\uFF71\uFF72\uFF73\uFF74\u201D)
input_ids:      | SOT | \uFF71 | \uFF72 | \uFF73 | \uFF74 | SEG |
token_type_ids: | 1   | 1 | 1 | 1 | 1 | 0  |
prefix_lm_mask:
SOT | 1 1 1 1 1 0 |
\uFF71   | 1 1 1 1 1 0 |
\uFF72   | 1 1 1 1 1 0 |
\uFF73   | 1 1 1 1 1 0 |
\uFF74   | 1 1 1 1 1 0 |
SEG | 1 1 1 1 1 1 |`),kr.forEach(n),gr.forEach(n),_r.forEach(n),fr.forEach(n),Bn=h(e),ht=s(e,"BLOCKQUOTE",{});var Tr=o(ht);Kt=s(Tr,"BLOCKQUOTE",{});var br=o(Kt);Qt=s(br,"BLOCKQUOTE",{});var vr=o(Qt);Yt=s(vr,"P",{});var jr=o(Yt);ns=i(jr,`x_token = tokenizer(\u201C\uFF73\uFF74\u201D, prefix_text=\u201C\uFF71\uFF72\u201D)
input_ids:      | SOT | \uFF71 | \uFF72 | SEG | \uFF73 | \uFF74 |
token_type_ids: | 1   | 1 | 1 | 0   | 0 | 0 |
prefix_lm_mask:
SOT | 1 1 1 0 0 0 |
\uFF71   | 1 1 1 0 0 0 |
\uFF72   | 1 1 1 0 0 0 |
SEG | 1 1 1 1 0 0 |
\uFF73   | 1 1 1 1 1 0 |
\uFF74   | 1 1 1 1 1 1 |`),jr.forEach(n),vr.forEach(n),br.forEach(n),Tr.forEach(n),Un=h(e),U=s(e,"H3",{class:!0});var ia=o(U);ie=s(ia,"A",{id:!0,class:!0,href:!0});var yr=o(ie);Xt=s(yr,"SPAN",{});var xr=o(Xt);b(qe.$$.fragment,xr),xr.forEach(n),yr.forEach(n),as=h(ia),Zt=s(ia,"SPAN",{});var $r=o(Zt);ss=i($r,"Spout Vector"),$r.forEach(n),ia.forEach(n),Rn=h(e),le=s(e,"P",{});var la=o(le);os=i(la,`A Spout Vector is a special vector for controlling text generation.
This vector is treated as the first embedding in self-attention to bring extraneous attention to the generated tokens.
In the pre-trained model published from `),en=s(la,"CODE",{});var Pr=o(en);rs=i(Pr,"Tanrei/GPTSAN-japanese"),Pr.forEach(n),is=i(la,`, the Spout Vector is a 128-dimensional vector that passes through 8 fully connected layers in the model and is projected into the space acting as external attention.
The Spout Vector projected by the fully connected layer is split to be passed to all self-attentions.`),la.forEach(n),Hn=h(e),R=s(e,"H2",{class:!0});var pa=o(R);pe=s(pa,"A",{id:!0,class:!0,href:!0});var Sr=o(pe);tn=s(Sr,"SPAN",{});var Gr=o(tn);b(Ee.$$.fragment,Gr),Gr.forEach(n),Sr.forEach(n),ls=h(pa),nn=s(pa,"SPAN",{});var wr=o(nn);ps=i(wr,"GPTSanJapaneseConfig"),wr.forEach(n),pa.forEach(n),Kn=h(e),N=s(e,"DIV",{class:!0});var kt=o(N);b(ze.$$.fragment,kt),ds=h(kt),H=s(kt,"P",{});var Tt=o(H);cs=i(Tt,"This is the configuration class to store the configuration of a "),ut=s(Tt,"A",{href:!0});var qr=o(ut);hs=i(qr,"GPTSanJapaneseModel"),qr.forEach(n),us=i(Tt,`. It is used to instantiate
a GPTSANJapanese model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the GPTSANJapanese
`),Ae=s(Tt,"A",{href:!0,rel:!0});var Er=o(Ae);ms=i(Er,"Tanrei/GPTSAN-japanese"),Er.forEach(n),fs=i(Tt," architecture."),Tt.forEach(n),_s=h(kt),K=s(kt,"P",{});var bt=o(K);gs=i(bt,"Configuration objects inherit from "),mt=s(bt,"A",{href:!0});var zr=o(mt);ks=i(zr,"PretrainedConfig"),zr.forEach(n),Ts=i(bt,` and can be used to control the model outputs. Read the
documentation from `),ft=s(bt,"A",{href:!0});var Ar=o(ft);bs=i(Ar,"PretrainedConfig"),Ar.forEach(n),vs=i(bt," for more information."),bt.forEach(n),kt.forEach(n),Qn=h(e),Q=s(e,"H2",{class:!0});var da=o(Q);de=s(da,"A",{id:!0,class:!0,href:!0});var Jr=o(de);an=s(Jr,"SPAN",{});var Mr=o(an);b(Je.$$.fragment,Mr),Mr.forEach(n),Jr.forEach(n),js=h(da),sn=s(da,"SPAN",{});var Nr=o(sn);ys=i(Nr,"GPTSanJapaneseTokenizer"),Nr.forEach(n),da.forEach(n),Yn=h(e),G=s(e,"DIV",{class:!0});var z=o(G);b(Me.$$.fragment,z),xs=h(z),on=s(z,"P",{});var Cr=o(on);$s=i(Cr,"This tokenizer is based on GPTNeoXJapaneseTokenizer and has the following modifications"),Cr.forEach(n),Ps=h(z),Y=s(z,"UL",{});var vt=o(Y);rn=s(vt,"LI",{});var Or=o(rn);Ss=i(Or,"Decoding byte0~byte255 tokens correctly"),Or.forEach(n),Gs=h(vt),ln=s(vt,"LI",{});var Fr=o(ln);ws=i(Fr,"Added bagofword token handling"),Fr.forEach(n),qs=h(vt),Ne=s(vt,"LI",{});var ca=o(Ne);Es=i(ca,`Return token_type_ids for Prefix-LM model
The bagofword token represents a repetition of the previous token and is converted to 3 consecutive tokens when
decoding In addition, the original Japanese special Sub-Word-Encoding has been released in this repository
(`),Ce=s(ca,"A",{href:!0,rel:!0});var Lr=o(Ce);zs=i(Lr,"https://github.com/tanreinama/Japanese-BPEEncoder_V2"),Lr.forEach(n),As=i(ca,`). The token_type_ids is a mask indicating the prefix input
position of the Prefix-LM model. To specify a prefix position, specify a prefix input for prefix_text, or specify a
sentence of the prefix part and the part after it as a text pair of batch input.`),ca.forEach(n),vt.forEach(n),Js=h(z),b(ce.$$.fragment,z),Ms=h(z),b(he.$$.fragment,z),Ns=h(z),b(ue.$$.fragment,z),Cs=h(z),me=s(z,"DIV",{class:!0});var ha=o(me);b(Oe.$$.fragment,ha),Os=h(ha),pn=s(ha,"P",{});var Ir=o(pn);Fs=i(Ir,"Converts a sequence of tokens (string) in a single string."),Ir.forEach(n),ha.forEach(n),Ls=h(z),C=s(z,"DIV",{class:!0});var jt=o(C);b(Fe.$$.fragment,jt),Is=h(jt),dn=s(jt,"P",{});var Dr=o(dn);Ds=i(Dr,`The tokenizer returns token_type_ids as separators between the Prefix part and the rest.
token_type_ids is 1 for the Prefix part and 0 for the rest of the token.`),Dr.forEach(n),Ws=h(jt),b(fe.$$.fragment,jt),jt.forEach(n),z.forEach(n),Xn=h(e),X=s(e,"H2",{class:!0});var ua=o(X);_e=s(ua,"A",{id:!0,class:!0,href:!0});var Wr=o(_e);cn=s(Wr,"SPAN",{});var Vr=o(cn);b(Le.$$.fragment,Vr),Vr.forEach(n),Wr.forEach(n),Vs=h(ua),hn=s(ua,"SPAN",{});var Br=o(hn);Bs=i(Br,"GPTSanJapaneseModel"),Br.forEach(n),ua.forEach(n),Zn=h(e),A=s(e,"DIV",{class:!0});var F=o(A);b(Ie.$$.fragment,F),Us=h(F),un=s(F,"P",{});var Ur=o(un);Rs=i(Ur,"The bare GPTSAN-japanese Model transformer outputting raw hidden-states without any specific head on top."),Ur.forEach(n),Hs=h(F),De=s(F,"P",{});var ma=o(De);Ks=i(ma,"The "),We=s(ma,"A",{href:!0,rel:!0});var Rr=o(We);Qs=i(Rr,"GPTSAN-japanese"),Rr.forEach(n),Ys=i(ma,` model was proposed in General-purpose Swich transformer
based Japanese language model`),ma.forEach(n),Xs=h(F),Ve=s(F,"P",{});var fa=o(Ve);Zs=i(fa,"This model is also a PyTorch "),Be=s(fa,"A",{href:!0,rel:!0});var Hr=o(Be);eo=i(Hr,"torch.nn.Module"),Hr.forEach(n),to=i(fa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),fa.forEach(n),no=h(F),O=s(F,"DIV",{class:!0});var yt=o(O);b(Ue.$$.fragment,yt),ao=h(yt),Z=s(yt,"P",{});var xt=o(Z);so=i(xt,"The "),_t=s(xt,"A",{href:!0});var Kr=o(_t);oo=i(Kr,"GPTSanJapaneseModel"),Kr.forEach(n),ro=i(xt," forward method, overrides the "),mn=s(xt,"CODE",{});var Qr=o(mn);io=i(Qr,"__call__"),Qr.forEach(n),lo=i(xt," special method."),xt.forEach(n),po=h(yt),b(ge.$$.fragment,yt),yt.forEach(n),F.forEach(n),ea=h(e),ee=s(e,"H2",{class:!0});var _a=o(ee);ke=s(_a,"A",{id:!0,class:!0,href:!0});var Yr=o(ke);fn=s(Yr,"SPAN",{});var Xr=o(fn);b(Re.$$.fragment,Xr),Xr.forEach(n),Yr.forEach(n),co=h(_a),_n=s(_a,"SPAN",{});var Zr=o(_n);ho=i(Zr,"GPTSanJapaneseForConditionalGeneration"),Zr.forEach(n),_a.forEach(n),ta=h(e),J=s(e,"DIV",{class:!0});var L=o(J);b(He.$$.fragment,L),uo=h(L),gn=s(L,"P",{});var ei=o(gn);mo=i(ei,"The bare GPTSAN-japanese Model with a language modeling head."),ei.forEach(n),fo=h(L),Ke=s(L,"P",{});var ga=o(Ke);_o=i(ga,"The "),Qe=s(ga,"A",{href:!0,rel:!0});var ti=o(Qe);go=i(ti,"GPTSAN-japanese"),ti.forEach(n),ko=i(ga,` model was proposed in General-purpose Swich transformer
based Japanese language model`),ga.forEach(n),To=h(L),Ye=s(L,"P",{});var ka=o(Ye);bo=i(ka,"This model is also a PyTorch "),Xe=s(ka,"A",{href:!0,rel:!0});var ni=o(Xe);vo=i(ni,"torch.nn.Module"),ni.forEach(n),jo=i(ka,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ka.forEach(n),yo=h(L),P=s(L,"DIV",{class:!0});var q=o(P);b(Ze.$$.fragment,q),xo=h(q),te=s(q,"P",{});var $t=o(te);$o=i($t,"The "),gt=s($t,"A",{href:!0});var ai=o(gt);Po=i(ai,"GPTSanJapaneseForConditionalGeneration"),ai.forEach(n),So=i($t," forward method, overrides the "),kn=s($t,"CODE",{});var si=o(kn);Go=i(si,"__call__"),si.forEach(n),wo=i($t," special method."),$t.forEach(n),qo=h(q),b(Te.$$.fragment,q),Eo=h(q),Tn=s(q,"P",{});var oi=o(Tn);zo=i(oi,"Example:"),oi.forEach(n),Ao=h(q),bn=s(q,"P",{});var ri=o(bn);Jo=i(ri,"Text Generation with regular LM Model"),ri.forEach(n),Mo=h(q),b(be.$$.fragment,q),No=h(q),vn=s(q,"P",{});var ii=o(vn);Co=i(ii,"Text Generation with Prefix-LM Model"),ii.forEach(n),Oo=h(q),b(ve.$$.fragment,q),Fo=h(q),jn=s(q,"P",{});var li=o(jn);Lo=i(li,"Simultaneously Text Generation And Masked Language Model"),li.forEach(n),Io=h(q),b(je.$$.fragment,q),q.forEach(n),L.forEach(n),this.h()},h(){m(p,"name","hf:doc:metadata"),m(p,"content",JSON.stringify($i)),m(_,"id","gptsanjapanese"),m(_,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(_,"href","#gptsanjapanese"),m(u,"class","relative group"),m(ne,"id","overview"),m(ne,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ne,"href","#overview"),m(D,"class","relative group"),m(ae,"id","generation"),m(ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ae,"href","#generation"),m(W,"class","relative group"),m(oe,"id","gptsan-features"),m(oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(oe,"href","#gptsan-features"),m(V,"class","relative group"),m(re,"id","prefixlm-model"),m(re,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(re,"href","#prefixlm-model"),m(B,"class","relative group"),m(ie,"id","spout-vector"),m(ie,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ie,"href","#spout-vector"),m(U,"class","relative group"),m(pe,"id","transformers.GPTSanJapaneseConfig"),m(pe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(pe,"href","#transformers.GPTSanJapaneseConfig"),m(R,"class","relative group"),m(ut,"href","/docs/transformers/v4.29.0/en/model_doc/gptsan-japanese#transformers.GPTSanJapaneseModel"),m(Ae,"href","https://huggingface.co/Tanrei/GPTSAN-japanese"),m(Ae,"rel","nofollow"),m(mt,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(ft,"href","/docs/transformers/v4.29.0/en/main_classes/configuration#transformers.PretrainedConfig"),m(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(de,"id","transformers.GPTSanJapaneseTokenizer"),m(de,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(de,"href","#transformers.GPTSanJapaneseTokenizer"),m(Q,"class","relative group"),m(Ce,"href","https://github.com/tanreinama/Japanese-BPEEncoder_V2"),m(Ce,"rel","nofollow"),m(me,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(_e,"id","transformers.GPTSanJapaneseModel"),m(_e,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(_e,"href","#transformers.GPTSanJapaneseModel"),m(X,"class","relative group"),m(We,"href","https://github.com/tanreinama/GPTSAN"),m(We,"rel","nofollow"),m(Be,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Be,"rel","nofollow"),m(_t,"href","/docs/transformers/v4.29.0/en/model_doc/gptsan-japanese#transformers.GPTSanJapaneseModel"),m(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ke,"id","transformers.GPTSanJapaneseForConditionalGeneration"),m(ke,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ke,"href","#transformers.GPTSanJapaneseForConditionalGeneration"),m(ee,"class","relative group"),m(Qe,"href","https://github.com/tanreinama/GPTSAN"),m(Qe,"rel","nofollow"),m(Xe,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Xe,"rel","nofollow"),m(gt,"href","/docs/transformers/v4.29.0/en/model_doc/gptsan-japanese#transformers.GPTSanJapaneseForConditionalGeneration"),m(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,d){t(document.head,p),f(e,k,d),f(e,u,d),t(u,_),t(_,$),v(l,$,null),t(u,g),t(u,M),t(M,Ta),f(e,qn,d),f(e,D,d),t(D,ne),t(ne,Pt),v($e,Pt,null),t(D,ba),t(D,St),t(St,va),f(e,En,d),f(e,st,d),t(st,ja),f(e,zn,d),f(e,ot,d),t(ot,ya),f(e,An,d),f(e,W,d),t(W,ae),t(ae,Gt),v(Pe,Gt,null),t(W,xa),t(W,wt),t(wt,$a),f(e,Jn,d),f(e,se,d),t(se,Pa),t(se,qt),t(qt,Sa),t(se,Ga),f(e,Mn,d),v(Se,e,d),f(e,Nn,d),f(e,V,d),t(V,oe),t(oe,Et),v(Ge,Et,null),t(V,wa),t(V,zt),t(zt,qa),f(e,Cn,d),f(e,rt,d),t(rt,Ea),f(e,On,d),f(e,B,d),t(B,re),t(re,At),v(we,At,null),t(B,za),t(B,Jt),t(Jt,Aa),f(e,Fn,d),f(e,S,d),t(S,Ja),t(S,Mt),t(Mt,Ma),t(S,Na),t(S,Nt),t(Nt,Ca),t(S,Oa),t(S,Ct),t(Ct,Fa),t(S,La),t(S,Ot),t(Ot,Ia),t(S,Da),t(S,Ft),t(Ft,Wa),t(S,Va),t(S,Lt),t(Lt,Ba),t(S,Ua),t(S,It),t(It,Ra),t(S,Ha),t(S,Dt),t(Dt,Ka),t(S,Qa),f(e,Ln,d),f(e,it,d),t(it,Ya),f(e,In,d),f(e,lt,d),t(lt,Xa),f(e,Dn,d),f(e,pt,d),t(pt,Za),f(e,Wn,d),f(e,dt,d),t(dt,Wt),t(Wt,Vt),t(Vt,Bt),t(Bt,es),f(e,Vn,d),f(e,ct,d),t(ct,Ut),t(Ut,Rt),t(Rt,Ht),t(Ht,ts),f(e,Bn,d),f(e,ht,d),t(ht,Kt),t(Kt,Qt),t(Qt,Yt),t(Yt,ns),f(e,Un,d),f(e,U,d),t(U,ie),t(ie,Xt),v(qe,Xt,null),t(U,as),t(U,Zt),t(Zt,ss),f(e,Rn,d),f(e,le,d),t(le,os),t(le,en),t(en,rs),t(le,is),f(e,Hn,d),f(e,R,d),t(R,pe),t(pe,tn),v(Ee,tn,null),t(R,ls),t(R,nn),t(nn,ps),f(e,Kn,d),f(e,N,d),v(ze,N,null),t(N,ds),t(N,H),t(H,cs),t(H,ut),t(ut,hs),t(H,us),t(H,Ae),t(Ae,ms),t(H,fs),t(N,_s),t(N,K),t(K,gs),t(K,mt),t(mt,ks),t(K,Ts),t(K,ft),t(ft,bs),t(K,vs),f(e,Qn,d),f(e,Q,d),t(Q,de),t(de,an),v(Je,an,null),t(Q,js),t(Q,sn),t(sn,ys),f(e,Yn,d),f(e,G,d),v(Me,G,null),t(G,xs),t(G,on),t(on,$s),t(G,Ps),t(G,Y),t(Y,rn),t(rn,Ss),t(Y,Gs),t(Y,ln),t(ln,ws),t(Y,qs),t(Y,Ne),t(Ne,Es),t(Ne,Ce),t(Ce,zs),t(Ne,As),t(G,Js),v(ce,G,null),t(G,Ms),v(he,G,null),t(G,Ns),v(ue,G,null),t(G,Cs),t(G,me),v(Oe,me,null),t(me,Os),t(me,pn),t(pn,Fs),t(G,Ls),t(G,C),v(Fe,C,null),t(C,Is),t(C,dn),t(dn,Ds),t(C,Ws),v(fe,C,null),f(e,Xn,d),f(e,X,d),t(X,_e),t(_e,cn),v(Le,cn,null),t(X,Vs),t(X,hn),t(hn,Bs),f(e,Zn,d),f(e,A,d),v(Ie,A,null),t(A,Us),t(A,un),t(un,Rs),t(A,Hs),t(A,De),t(De,Ks),t(De,We),t(We,Qs),t(De,Ys),t(A,Xs),t(A,Ve),t(Ve,Zs),t(Ve,Be),t(Be,eo),t(Ve,to),t(A,no),t(A,O),v(Ue,O,null),t(O,ao),t(O,Z),t(Z,so),t(Z,_t),t(_t,oo),t(Z,ro),t(Z,mn),t(mn,io),t(Z,lo),t(O,po),v(ge,O,null),f(e,ea,d),f(e,ee,d),t(ee,ke),t(ke,fn),v(Re,fn,null),t(ee,co),t(ee,_n),t(_n,ho),f(e,ta,d),f(e,J,d),v(He,J,null),t(J,uo),t(J,gn),t(gn,mo),t(J,fo),t(J,Ke),t(Ke,_o),t(Ke,Qe),t(Qe,go),t(Ke,ko),t(J,To),t(J,Ye),t(Ye,bo),t(Ye,Xe),t(Xe,vo),t(Ye,jo),t(J,yo),t(J,P),v(Ze,P,null),t(P,xo),t(P,te),t(te,$o),t(te,gt),t(gt,Po),t(te,So),t(te,kn),t(kn,Go),t(te,wo),t(P,qo),v(Te,P,null),t(P,Eo),t(P,Tn),t(Tn,zo),t(P,Ao),t(P,bn),t(bn,Jo),t(P,Mo),v(be,P,null),t(P,No),t(P,vn),t(vn,Co),t(P,Oo),v(ve,P,null),t(P,Fo),t(P,jn),t(jn,Lo),t(P,Io),v(je,P,null),na=!0},p(e,[d]){const et={};d&2&&(et.$$scope={dirty:d,ctx:e}),ce.$set(et);const yn={};d&2&&(yn.$$scope={dirty:d,ctx:e}),he.$set(yn);const xn={};d&2&&(xn.$$scope={dirty:d,ctx:e}),ue.$set(xn);const $n={};d&2&&($n.$$scope={dirty:d,ctx:e}),fe.$set($n);const tt={};d&2&&(tt.$$scope={dirty:d,ctx:e}),ge.$set(tt);const Pn={};d&2&&(Pn.$$scope={dirty:d,ctx:e}),Te.$set(Pn);const Sn={};d&2&&(Sn.$$scope={dirty:d,ctx:e}),be.$set(Sn);const Gn={};d&2&&(Gn.$$scope={dirty:d,ctx:e}),ve.$set(Gn);const wn={};d&2&&(wn.$$scope={dirty:d,ctx:e}),je.$set(wn)},i(e){na||(j(l.$$.fragment,e),j($e.$$.fragment,e),j(Pe.$$.fragment,e),j(Se.$$.fragment,e),j(Ge.$$.fragment,e),j(we.$$.fragment,e),j(qe.$$.fragment,e),j(Ee.$$.fragment,e),j(ze.$$.fragment,e),j(Je.$$.fragment,e),j(Me.$$.fragment,e),j(ce.$$.fragment,e),j(he.$$.fragment,e),j(ue.$$.fragment,e),j(Oe.$$.fragment,e),j(Fe.$$.fragment,e),j(fe.$$.fragment,e),j(Le.$$.fragment,e),j(Ie.$$.fragment,e),j(Ue.$$.fragment,e),j(ge.$$.fragment,e),j(Re.$$.fragment,e),j(He.$$.fragment,e),j(Ze.$$.fragment,e),j(Te.$$.fragment,e),j(be.$$.fragment,e),j(ve.$$.fragment,e),j(je.$$.fragment,e),na=!0)},o(e){y(l.$$.fragment,e),y($e.$$.fragment,e),y(Pe.$$.fragment,e),y(Se.$$.fragment,e),y(Ge.$$.fragment,e),y(we.$$.fragment,e),y(qe.$$.fragment,e),y(Ee.$$.fragment,e),y(ze.$$.fragment,e),y(Je.$$.fragment,e),y(Me.$$.fragment,e),y(ce.$$.fragment,e),y(he.$$.fragment,e),y(ue.$$.fragment,e),y(Oe.$$.fragment,e),y(Fe.$$.fragment,e),y(fe.$$.fragment,e),y(Le.$$.fragment,e),y(Ie.$$.fragment,e),y(Ue.$$.fragment,e),y(ge.$$.fragment,e),y(Re.$$.fragment,e),y(He.$$.fragment,e),y(Ze.$$.fragment,e),y(Te.$$.fragment,e),y(be.$$.fragment,e),y(ve.$$.fragment,e),y(je.$$.fragment,e),na=!1},d(e){n(p),e&&n(k),e&&n(u),x(l),e&&n(qn),e&&n(D),x($e),e&&n(En),e&&n(st),e&&n(zn),e&&n(ot),e&&n(An),e&&n(W),x(Pe),e&&n(Jn),e&&n(se),e&&n(Mn),x(Se,e),e&&n(Nn),e&&n(V),x(Ge),e&&n(Cn),e&&n(rt),e&&n(On),e&&n(B),x(we),e&&n(Fn),e&&n(S),e&&n(Ln),e&&n(it),e&&n(In),e&&n(lt),e&&n(Dn),e&&n(pt),e&&n(Wn),e&&n(dt),e&&n(Vn),e&&n(ct),e&&n(Bn),e&&n(ht),e&&n(Un),e&&n(U),x(qe),e&&n(Rn),e&&n(le),e&&n(Hn),e&&n(R),x(Ee),e&&n(Kn),e&&n(N),x(ze),e&&n(Qn),e&&n(Q),x(Je),e&&n(Yn),e&&n(G),x(Me),x(ce),x(he),x(ue),x(Oe),x(Fe),x(fe),e&&n(Xn),e&&n(X),x(Le),e&&n(Zn),e&&n(A),x(Ie),x(Ue),x(ge),e&&n(ea),e&&n(ee),x(Re),e&&n(ta),e&&n(J),x(He),x(Ze),x(Te),x(be),x(ve),x(je)}}}const $i={local:"gptsanjapanese",sections:[{local:"overview",sections:[{local:"generation",title:"Generation"}],title:"Overview"},{local:"gptsan-features",sections:[{local:"prefixlm-model",title:"Prefix-LM Model"},{local:"spout-vector",title:"Spout Vector"}],title:"GPTSAN Features"},{local:"transformers.GPTSanJapaneseConfig",title:"GPTSanJapaneseConfig"},{local:"transformers.GPTSanJapaneseTokenizer",title:"GPTSanJapaneseTokenizer"},{local:"transformers.GPTSanJapaneseModel",title:"GPTSanJapaneseModel"},{local:"transformers.GPTSanJapaneseForConditionalGeneration",title:"GPTSanJapaneseForConditionalGeneration"}],title:"GPTSAN-japanese"};function Pi(w){return mi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ai extends di{constructor(p){super();ci(this,p,Pi,xi,hi,{})}}export{Ai as default,$i as metadata};
