File size: 4,301 Bytes
2f7bb82
 
01d7523
2f7bb82
 
 
 
 
01d7523
 
2f7bb82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f1524db
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
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.