gpt_neox_client 0.1.0 → 0.2.0
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/CHANGELOG.md +6 -1
- data/README.md +3 -3
- data/ext/gpt_neox_client/extconf.rb +26 -0
- data/ext/gpt_neox_client/gpt_neox_client.cpp +2 -1
- data/lib/gpt_neox_client/version.rb +1 -1
- 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: e76735b1c4c6a4e228620bd4cd3ab20d02d0b20505eb85acbcab263301ad4e49
|
4
|
+
data.tar.gz: 05d285d7b1daa24408c1087f0c748a456a8398d45c59b3b311e1d0a4413df00a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dda9974e3d4d1023ec0e8783922c6cb779b41d0083aa26bdfb73e69778de353eee9b26d5185ea0f160bec07df89ec9f34267dd2c42e02f0d95bc224fb4b4a43a
|
7
|
+
data.tar.gz: 0a2c389774a0e49b8b6f4ee2dac8bea96f5d1608ef4b4ac9cef95f29480fc23f4cbc19c14be97781e9076eee3a9fd247883c979390ff1fd2385159c42a12189e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -38,15 +38,15 @@ japanese-large-lm-3.6b-instruction-sft/ggml-model-f16.bin
|
|
38
38
|
```
|
39
39
|
|
40
40
|
```ruby
|
41
|
-
require
|
41
|
+
require 'gpt_neox_client'
|
42
42
|
|
43
|
-
client = GPTNeoXClient.new('japanese-large-lm-3.6b-instruction-sft/ggml-model-f16.bin', seed: 123456789, n_threads: 4)
|
43
|
+
client = GPTNeoXClient.new(path: 'japanese-large-lm-3.6b-instruction-sft/ggml-model-f16.bin', seed: 123456789, n_threads: 4)
|
44
44
|
puts client.completions(
|
45
45
|
'ユーザー:四国の県名を全て列挙してください。<0x0A>システム:',
|
46
46
|
top_p: 0.9,
|
47
47
|
top_k: 1,
|
48
48
|
temperature: 0.7
|
49
|
-
).gsub(
|
49
|
+
).gsub('<0x0A>', "\n").gsub('</s>', '')
|
50
50
|
#
|
51
51
|
# ユーザー:四国の県名を全て列挙してください。
|
52
52
|
# システム:徳島県、香川県、愛媛県、高知県
|
@@ -22,4 +22,30 @@ $INCFLAGS << ' -I$(srcdir)/src/ggml'
|
|
22
22
|
$VPATH << '$(srcdir)/src'
|
23
23
|
$VPATH << '$(srcdir)/src/ggml'
|
24
24
|
|
25
|
+
if RUBY_PLATFORM.match?(/darwin|linux|bsd/) && try_compile('#include <stdio.h>', '-pthread')
|
26
|
+
$CFLAGS << ' -pthread'
|
27
|
+
$CXXFLAGS << ' -pthread'
|
28
|
+
end
|
29
|
+
|
30
|
+
if RUBY_PLATFORM.match?(/darwin/)
|
31
|
+
if have_framework('Accelerate')
|
32
|
+
$CFLAGS << ' -DGGML_USE_ACCELERATE'
|
33
|
+
else
|
34
|
+
warning 'Accelerate framework is not found.'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
$CFLAGS << ' -DGGML_USE_OPENBLAS' if !RUBY_PLATFORM.match?(/darwin/) && (have_library('openblas') && have_header('cblas.h'))
|
39
|
+
|
25
40
|
create_makefile('gpt_neox_client/gpt_neox_client')
|
41
|
+
|
42
|
+
if RUBY_PLATFORM.match?(/darwin/)
|
43
|
+
File.open('Makefile', 'a') do |f|
|
44
|
+
f.puts "\nggml-metal.o: ggml-metal.m ggml-metal.h"
|
45
|
+
f.puts "\t$(CC) $(CFLAGS) -c $< -o $@"
|
46
|
+
end
|
47
|
+
|
48
|
+
metal_path = File.expand_path("#{__dir__}/src/ggml/ggml-metal.metal")
|
49
|
+
dest_path = File.expand_path("#{__dir__}/../../lib/gpt_neox_client/")
|
50
|
+
FileUtils.cp(metal_path, dest_path)
|
51
|
+
end
|
@@ -208,6 +208,7 @@ static VALUE gpt_neox_client_completions(int argc, VALUE* argv, VALUE self) {
|
|
208
208
|
std::mt19937 rng(seed);
|
209
209
|
std::vector<gpt_vocab::id> embd;
|
210
210
|
std::vector<int32_t> last_n_tokens(model->hparams.n_ctx, 0);
|
211
|
+
gpt_vocab::id token_eos = vocab->token_to_id["</s>"];
|
211
212
|
|
212
213
|
while (n_sampled < n_predict) {
|
213
214
|
if (embd.size() > 0) {
|
@@ -240,7 +241,7 @@ static VALUE gpt_neox_client_completions(int argc, VALUE* argv, VALUE self) {
|
|
240
241
|
}
|
241
242
|
|
242
243
|
for (auto id : embd) completions += vocab->id_to_token[id];
|
243
|
-
if (embd.back() ==
|
244
|
+
if (!embd.empty() && embd.back() == token_eos) break;
|
244
245
|
}
|
245
246
|
|
246
247
|
RB_GC_GUARD(prompt_);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpt_neox_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshoku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: gpt_neox_client is a simple client for GPT-NeoX.
|
14
14
|
email:
|