nlpcloud 1.0.11 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nlpcloud.rb +18 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7a5cf9c2df4c28f9f5b880d8becfc560adcd1578b6b2b1c84fc41adfd4a4451
|
4
|
+
data.tar.gz: 89137b44db071f0cae6400dab96a1f28e5550aa0d470f0814efd9e888b98c41c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c8de92b7d3f71708f54265a8dfbc09a004f7025afb28965bab867df9352c2c7e6fa990fff60c18286707ff5b214f7443d7c4a236a3d70017cae2499332d64e0
|
7
|
+
data.tar.gz: b26ea1c63cbee49c1622fda01f7a5f1a2abc3d4a1cac44920cea52e11fc359a5a38f897570a6c53cb75b5d00bf0bedc9760b7ed537f39a84ca6e259810666d3b
|
data/lib/nlpcloud.rb
CHANGED
@@ -9,14 +9,19 @@ module NLPCloud
|
|
9
9
|
|
10
10
|
# Client requests the API.
|
11
11
|
class Client
|
12
|
-
def initialize(model, token, gpu: false)
|
12
|
+
def initialize(model, token, gpu: false, lang: '')
|
13
13
|
@headers = {
|
14
14
|
'Authorization' => "Token #{token}",
|
15
|
-
|
15
|
+
'Content-Type' => 'application/json',
|
16
|
+
'User-Agent' => 'nlpcloud-ruby-client'
|
16
17
|
}
|
17
18
|
|
18
|
-
@root_url = if gpu
|
19
|
+
@root_url = if gpu && (lang != '')
|
20
|
+
"#{BASE_URL}/#{API_VERSION}/gpu/#{lang}/#{model}"
|
21
|
+
elsif gpu && (lang == '')
|
19
22
|
"#{BASE_URL}/#{API_VERSION}/gpu/#{model}"
|
23
|
+
elsif !gpu && (lang != '')
|
24
|
+
"#{BASE_URL}/#{API_VERSION}/#{lang}/#{model}"
|
20
25
|
else
|
21
26
|
"#{BASE_URL}/#{API_VERSION}/#{model}"
|
22
27
|
end
|
@@ -41,8 +46,9 @@ module NLPCloud
|
|
41
46
|
end
|
42
47
|
|
43
48
|
def generation(text, min_length: nil, max_length: nil, length_no_input: nil,
|
44
|
-
end_sequence: nil, remove_input: nil,
|
45
|
-
|
49
|
+
end_sequence: nil, remove_input: nil, do_sample: nil, num_beams: nil, early_stopping: nil,
|
50
|
+
no_repeat_ngram_size: nil, num_return_sequences: nil, top_k: nil, top_p: nil,
|
51
|
+
temperature: nil, repetition_penalty: nil, length_penalty: nil, bad_words: nil)
|
46
52
|
payload = {
|
47
53
|
'text' => text,
|
48
54
|
'min_length' => min_length,
|
@@ -50,11 +56,17 @@ module NLPCloud
|
|
50
56
|
'length_no_input' => length_no_input,
|
51
57
|
'end_sequence' => end_sequence,
|
52
58
|
'remove_input' => remove_input,
|
59
|
+
'do_sample' => do_sample,
|
60
|
+
'num_beams' => num_beams,
|
61
|
+
'early_stopping' => early_stopping,
|
62
|
+
'no_repeat_ngram_size' => no_repeat_ngram_size,
|
63
|
+
'num_return_sequences' => num_return_sequences,
|
53
64
|
'top_k' => top_k,
|
54
65
|
'top_p' => top_p,
|
55
66
|
'temperature' => temperature,
|
56
67
|
'repetition_penalty' => repetition_penalty,
|
57
|
-
'length_penalty' => length_penalty
|
68
|
+
'length_penalty' => length_penalty,
|
69
|
+
'bad_words' => bad_words
|
58
70
|
}
|
59
71
|
response = RestClient.post("#{@root_url}/generation", payload.to_json, @headers)
|
60
72
|
JSON.parse(response.body)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nlpcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Salinas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'NLP Cloud serves high performance pre-trained or custom models for NER,
|
14
14
|
sentiment-analysis, classification, summarization, text generation, question answering,
|