|
--- |
|
library_name: transformers |
|
license: mit |
|
metrics: |
|
- accuracy |
|
pipeline_tag: text-generation |
|
tags: |
|
- text-generation-inference |
|
language: |
|
- en |
|
--- |
|
|
|
# AgriBrain's AI-core, agbrain |
|
--- |
|
AbriBrain's AI-core, agbrain, is a cutting-edge natural |
|
language processing (NLP) model built specifically for |
|
generating content related to agriculture. The model is a |
|
fine-tuned version of the popular GPT-2 language model, trained |
|
on a vast corpus of 1601 PDF documents sourced from various |
|
reputable online resources. |
|
|
|
Agbrain has been specifically designed to cater to the needs |
|
of the agriculture industry, including farmers, agronomists, |
|
agricultural researchers, and other stakeholders. |
|
|
|
One of the key strengths of Agbrain is its ability to generate |
|
coherent, and contextually relevant content. The model has been |
|
fine-tuned using advanced machine learning techniques to ensure |
|
that the generated content is both accurate and informative. It |
|
is capable of producing content on a wide range of topics, |
|
including crop cultivation, livestock management, pest control, |
|
irrigation, and more. |
|
|
|
Overall, Agbrain is a powerful and versatile NLP model that is |
|
perfectly suited to the needs of the agriculture industry. |
|
|
|
# Usage |
|
--- |
|
|
|
## Transformers and model.generate |
|
--- |
|
```python |
|
import tensorflow as tf |
|
from transformers import TFGPT2LMHeadModel, GPT2Tokenizer |
|
|
|
tokenizer = GPT2Tokenizer.from_pretrained("benkimz/agbrain") |
|
model = TFGPT2LMHeadModel.from_pretrained("benkimz/agbrain") |
|
|
|
prompt = """ |
|
I think agribusiness is a great opportunity for passionate |
|
investors. From food business to growing crops for sale, |
|
and rearing livestock for business. |
|
""" |
|
|
|
input_ids = tokenizer.encode(prompt, return_tensors="tf") |
|
outputs = model.generate(input_ids=input_ids, |
|
max_length=120, |
|
do_sample=True) |
|
generated_text = tokenizer.decode(outputs[0], |
|
skip_special_tokens=True) |
|
|
|
print(generated_text) |
|
|
|
# Output |
|
""" |
|
I think agribusiness is a great opportunity for passionate |
|
investors. From food business to growing crops for sale, |
|
and rearing livestock for business. |
|
|
|
In this paper I will introduce a concept model agribusiness |
|
that focuses on businesses to grow large amounts of product. |
|
This model requires that product be sold outside of |
|
agriculture industry, thus allowing farmers advantages, |
|
especially over agronomic competition in production. |
|
model is very important to farmers as it will be possible, |
|
to sell their products at local markets without |
|
""" |
|
``` |
|
## Transformers pipeline |
|
--- |
|
```python |
|
from transformers import pipeline, set_seed |
|
generator = pipeline('text-generation', model='benkimz/agbrain') |
|
set_seed(42) |
|
|
|
samples = generator( |
|
"Animal husbandry is an important part of livestock production.", |
|
max_length=100, |
|
num_return_sequences=2 |
|
) |
|
|
|
for sample in samples: |
|
print("Model output: {}\n".format(sample['generated_text'])) |
|
|
|
|
|
# Output |
|
""" |
|
**Model output**: Animal husbandry is an important part of |
|
livestock production. livestock production industry is complex, |
|
many factors contribute to this complexity. need to determine |
|
most efficient method of handling livestock to ensure best quality |
|
product. It is important that animals being handled appropriately |
|
have properly cleaned equipment that prevents scratching |
|
(Sappell 2002). Because livestock is an important part of |
|
livestock production, veterinary care must be taken regularly |
|
during transport of animals from a farm to your home to be |
|
successful. If livestock were to be |
|
|
|
**Model output**: Animal husbandry is an important part of |
|
livestock production. Animal husbandry combines various |
|
strategies to control pests. Management strategies of pest |
|
management strategies |
|
Preventing pest from reaching level |
|
Preventing pest from reaching level |
|
To minimize transmission costs, control mechanisms |
|
must be developed to prevent pest from reaching level. In |
|
order to have an accurate information about pest |
|
management methods, instrumental field study of pest management |
|
measures be developed by field of study. A technique of this |
|
""" |
|
``` |
|
|
|
# Metrics |
|
--- |
|
Step|Training Loss |
|
----|--------------- |
|
500|3.877700 |
|
1000|3.746200 |
|
1500|3.659600 |
|
2000|3.613300 |
|
2500|3.603400 |
|
3000|3.561600 |
|
3500|3.558300 |
|
4000|3.518400 |
|
4500|3.504100 |
|
5000|3.508600 |
|
--- |
|
|
|
Further training could improve the model and make it better. |