Closed maria-18-git closed 8 months ago
model_name
as input parameter.
model_name=EleutherAI/gpt-j-6B
by default
maria@chai ~/axs/core_collection/workflows_collection/gptj/gptj_predict_next_word_demo (master *=)$ axs byname gptj_predict_next_word_demo , run
...
/home/maria/bin/python3 /home/maria/axs/core_collection/workflows_collection/gptj/gptj_predict_next_word_demo/gptj_next_word_demo.py "EleutherAI/gpt-j-6B" "lambada"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Next-word prediction :
Tokenizer has been done.
Model has been done.
Input sequence: Machine learning is an umbrella term for solving
Tokenized input data structure: {'input_ids': tensor([[37573, 4673, 318, 281, 25510, 3381, 329, 18120]]), 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1]])}
Token IDs and their words: tensor(37573) Machine tensor(4673) learning tensor(318) is tensor(281) an tensor(25510) umbrella tensor(3381) term tensor(329) for tensor(18120) solving All logits for next word: tensor([[ 6.2739, 7.4044, 3.0768, ..., -7.1449, -6.9499, -7.3172]]) torch.Size([1, 50400]) Predicted token ID of next word 2761 Predicted next word for sequence: problems
End demo 0
- `model_name=gpt2`
maria@chai ~/axs/core_collection/workflows_collection/gptj/gptj_predict_next_word_demo (master *=)$ axs byname gptj_predict_next_word_demo , run --model_name=gpt2 ... /home/maria/bin/python3 /home/maria/axs/core_collection/workflows_collection/gptj/gptj_predict_next_word_demo/gptj_next_word_demo.py "gpt2" "lambada" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Next-word prediction : Tokenizer has been done. Model has been done.
Input sequence: Machine learning is an umbrella term for solving Tokenized input data structure: {'input_ids': tensor([[37573, 4673, 318, 281, 25510, 3381, 329, 18120]]), 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1]])}
Token IDs and their words: tensor(37573) Machine tensor(4673) learning tensor(318) is tensor(281) an tensor(25510) umbrella tensor(3381) term tensor(329) for tensor(18120) solving All logits for next word: tensor([[-118.3903, -116.6987, -123.4514, ..., -122.0444, -126.3650, -119.0872]]) torch.Size([1, 50257]) Predicted token ID of next word 2761 Predicted next word for sequence: problems
End demo 0
Commit(Oct 2, 2023): Added gptj_predict_next_word_demo
Status: Done.
Using an example https://jamesmccaffrey.wordpress.com/2021/10/21/a-predict-next-word-example-using-hugging-face-and-gpt-2/hug_next_word_gpt2_demo/ create program
gptj_predict_next_word_demo
for prediction of next word in text. Input parameters - model, dataset. Check for different models and dataset.