nlpcloud 1.0.10 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/nlpcloud.rb +30 -2
 - 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: 5a625122c70741c70a1d3bf335696ade3bfc453f069f85c57737ee457509ba18
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 496cc60651689612fd01f6d73d22242ec559eb139241debd7fe6367cb725cfda
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 76b87c80b41bd0ce5c6640c82565f93dcdcf7dc0689784c82020f88bafc95503ef97531e1491e03cd63f73d45a731feff04e2c6d776d05c3fc2c90f009a10632
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: '04281a7294ffebc7bb448d190cb617aaba7755d7d6b461e4d353eb4120083127c96db5c42dee219df36a76710a4f4ca61b5836c41a75b1ed2670e13277ce49e8'
         
     | 
    
        data/lib/nlpcloud.rb
    CHANGED
    
    | 
         @@ -12,7 +12,8 @@ module NLPCloud 
     | 
|
| 
       12 
12 
     | 
    
         
             
                def initialize(model, token, gpu: false)
         
     | 
| 
       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 
19 
     | 
    
         
             
                  @root_url = if gpu
         
     | 
| 
         @@ -30,7 +31,7 @@ module NLPCloud 
     | 
|
| 
       30 
31 
     | 
    
         
             
                  JSON.parse(response.body)
         
     | 
| 
       31 
32 
     | 
    
         
             
                end
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                def classification(text, labels, multi_class)
         
     | 
| 
      
 34 
     | 
    
         
            +
                def classification(text, labels, multi_class: nil)
         
     | 
| 
       34 
35 
     | 
    
         
             
                  payload = {
         
     | 
| 
       35 
36 
     | 
    
         
             
                    'text' => text,
         
     | 
| 
       36 
37 
     | 
    
         
             
                    'labels' => labels,
         
     | 
| 
         @@ -40,6 +41,33 @@ module NLPCloud 
     | 
|
| 
       40 
41 
     | 
    
         
             
                  JSON.parse(response.body)
         
     | 
| 
       41 
42 
     | 
    
         
             
                end
         
     | 
| 
       42 
43 
     | 
    
         | 
| 
      
 44 
     | 
    
         
            +
                def generation(text, min_length: nil, max_length: nil, length_no_input: nil,
         
     | 
| 
      
 45 
     | 
    
         
            +
                               end_sequence: nil, remove_input: nil, do_sample: nil, num_beams: nil, early_stopping: nil,
         
     | 
| 
      
 46 
     | 
    
         
            +
                               no_repeat_ngram_size: nil, num_return_sequences: nil, top_k: nil, top_p: nil,
         
     | 
| 
      
 47 
     | 
    
         
            +
                               temperature: nil, repetition_penalty: nil, length_penalty: nil, bad_words: nil)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  payload = {
         
     | 
| 
      
 49 
     | 
    
         
            +
                    'text' => text,
         
     | 
| 
      
 50 
     | 
    
         
            +
                    'min_length' => min_length,
         
     | 
| 
      
 51 
     | 
    
         
            +
                    'max_length' => max_length,
         
     | 
| 
      
 52 
     | 
    
         
            +
                    'length_no_input' => length_no_input,
         
     | 
| 
      
 53 
     | 
    
         
            +
                    'end_sequence' => end_sequence,
         
     | 
| 
      
 54 
     | 
    
         
            +
                    'remove_input' => remove_input,
         
     | 
| 
      
 55 
     | 
    
         
            +
                    'do_sample' => do_sample,
         
     | 
| 
      
 56 
     | 
    
         
            +
                    'num_beams' => num_beams,
         
     | 
| 
      
 57 
     | 
    
         
            +
                    'early_stopping' => early_stopping,
         
     | 
| 
      
 58 
     | 
    
         
            +
                    'no_repeat_ngram_size' => no_repeat_ngram_size,
         
     | 
| 
      
 59 
     | 
    
         
            +
                    'num_return_sequences' => num_return_sequences,
         
     | 
| 
      
 60 
     | 
    
         
            +
                    'top_k' => top_k,
         
     | 
| 
      
 61 
     | 
    
         
            +
                    'top_p' => top_p,
         
     | 
| 
      
 62 
     | 
    
         
            +
                    'temperature' => temperature,
         
     | 
| 
      
 63 
     | 
    
         
            +
                    'repetition_penalty' => repetition_penalty,
         
     | 
| 
      
 64 
     | 
    
         
            +
                    'length_penalty' => length_penalty,
         
     | 
| 
      
 65 
     | 
    
         
            +
                    'bad_words' => bad_words
         
     | 
| 
      
 66 
     | 
    
         
            +
                  }
         
     | 
| 
      
 67 
     | 
    
         
            +
                  response = RestClient.post("#{@root_url}/generation", payload.to_json, @headers)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  JSON.parse(response.body)
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
       43 
71 
     | 
    
         
             
                def sentiment(text)
         
     | 
| 
       44 
72 
     | 
    
         
             
                  payload = {
         
     | 
| 
       45 
73 
     | 
    
         
             
                    'text' => text
         
     | 
    
        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.14
         
     | 
| 
       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-10 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,
         
     |