初始化项目,由ModelHub XC社区提供模型
Model: macedonizer/hr-gpt2 Source: Original Platform
This commit is contained in:
17
.gitattributes
vendored
Normal file
17
.gitattributes
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
64
README.md
Normal file
64
README.md
Normal file
@@ -0,0 +1,64 @@
|
||||
---
|
||||
language:
|
||||
- hr
|
||||
thumbnail: https://huggingface.co/macedonizer/hr-gpt2/lets-talk-about-nlp-hr.jpg
|
||||
license: apache-2.0
|
||||
datasets:
|
||||
- wiki-hr
|
||||
---
|
||||
|
||||
# hr-gpt2
|
||||
Test the whole generation capabilities here: https://transformer.huggingface.co/doc/gpt2-large
|
||||
Pretrained model on English language using a causal language modeling (CLM) objective. It was introduced in
|
||||
[this paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf)
|
||||
and first released at [this page](https://openai.com/blog/better-language-models/).
|
||||
|
||||
## Model description
|
||||
hr-gpt2 is a transformers model pretrained on a very large corpus of Croation data in a self-supervised fashion. This
|
||||
means it was pretrained on the raw texts only, with no humans labeling them in any way (which is why it can use lots
|
||||
of publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely,
|
||||
it was trained to guess the next word in sentences.
|
||||
More precisely, inputs are sequences of the continuous text of a certain length and the targets are the same sequence,
|
||||
shifted one token (word or piece of the word) to the right. The model uses internally a mask-mechanism to make sure the
|
||||
predictions for the token `i` only uses the inputs from `1` to `i` but not the future tokens.
|
||||
This way, the model learns an inner representation of the Macedonian language that can then be used to extract features
|
||||
useful for downstream tasks. The model is best at what it was pretrained for, however, which is generating texts from a
|
||||
prompt.
|
||||
|
||||
### How to use
|
||||
Here is how to use this model to get the features of a given text in PyTorch:
|
||||
|
||||
import random \\nfrom transformers import AutoTokenizer, AutoModelWithLMHead
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained('macedonizer/hr-gpt2') \
|
||||
model = AutoModelWithLMHead.from_pretrained('macedonizer/sr-gpt2')
|
||||
|
||||
input_text = 'Ja sam bio '
|
||||
|
||||
if len(input_text) == 0: \
|
||||
encoded_input = tokenizer(input_text, return_tensors="pt") \
|
||||
output = model.generate( \
|
||||
bos_token_id=random.randint(1, 50000), \
|
||||
do_sample=True, \
|
||||
top_k=50, \
|
||||
max_length=1024, \
|
||||
top_p=0.95, \
|
||||
num_return_sequences=1, \
|
||||
) \
|
||||
else: \
|
||||
encoded_input = tokenizer(input_text, return_tensors="pt") \
|
||||
output = model.generate( \
|
||||
**encoded_input, \
|
||||
bos_token_id=random.randint(1, 50000), \
|
||||
do_sample=True, \
|
||||
top_k=50, \
|
||||
max_length=1024, \
|
||||
top_p=0.95, \
|
||||
num_return_sequences=1, \
|
||||
)
|
||||
|
||||
decoded_output = [] \
|
||||
for sample in output: \
|
||||
decoded_output.append(tokenizer.decode(sample, skip_special_tokens=True))
|
||||
|
||||
print(decoded_output)
|
||||
30
config.json
Normal file
30
config.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"activation_function": "gelu_new",
|
||||
"architectures": [
|
||||
"GPT2LMHeadModel"
|
||||
],
|
||||
"attn_pdrop": 0.1,
|
||||
"bos_token_id": 0,
|
||||
"embd_pdrop": 0.1,
|
||||
"eos_token_id": 2,
|
||||
"gradient_checkpointing": false,
|
||||
"initializer_range": 0.02,
|
||||
"layer_norm_epsilon": 1e-05,
|
||||
"model_type": "gpt2",
|
||||
"n_ctx": 1024,
|
||||
"n_embd": 768,
|
||||
"n_head": 12,
|
||||
"n_inner": null,
|
||||
"n_layer": 12,
|
||||
"n_positions": 1024,
|
||||
"resid_pdrop": 0.1,
|
||||
"scale_attn_weights": true,
|
||||
"summary_activation": null,
|
||||
"summary_first_dropout": 0.1,
|
||||
"summary_proj_to_labels": true,
|
||||
"summary_type": "cls_index",
|
||||
"summary_use_proj": true,
|
||||
"transformers_version": "4.6.1",
|
||||
"use_cache": true,
|
||||
"vocab_size": 52000
|
||||
}
|
||||
BIN
lets-talk-about-nlp-hr.jpg
Normal file
BIN
lets-talk-about-nlp-hr.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 142 KiB |
51740
merges.txt
Normal file
51740
merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:43f9aa53870e53cc45965b87137b69dd8ed72e7aac32222ec0fa22f2bf137fe8
|
||||
size 515758313
|
||||
3
training_args.bin
Normal file
3
training_args.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c35c1f76fff922e01f442bab83c8f1c3d114a87966eed2ce5e6aaee437ccdd04
|
||||
size 2479
|
||||
1
vocab.json
Normal file
1
vocab.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user