vccarvalho11 commited on
Commit
f2bd10f
·
verified ·
1 Parent(s): 5e27338

Upload T5-LM-Large-text2sql-spider ONNX model

Browse files
README.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: onnx
3
+ tags:
4
+ - text2text-generation
5
+ - t5
6
+ - text-to-sql
7
+ - sql
8
+ - spider
9
+ - encoder-decoder
10
+ - onnx
11
+ - inference4j
12
+ license: apache-2.0
13
+ pipeline_tag: text2text-generation
14
+ datasets:
15
+ - spider
16
+ - spider-syn
17
+ ---
18
+
19
+ # T5-LM-Large text2sql-spider — ONNX
20
+
21
+ ONNX export of [T5-LM-Large-text2sql-spider](https://huggingface.co/gaussalgo/T5-LM-Large-text2sql-spider) (0.8B parameters) with encoder-decoder architecture and KV cache support.
22
+
23
+ This is a T5-large model fine-tuned on the Spider and Spider-Syn datasets for text-to-SQL generation. Given a natural language question and a database schema, it produces the corresponding SQL query.
24
+
25
+ Converted for use with [inference4j](https://github.com/inference4j/inference4j), an inference-only AI library for Java.
26
+
27
+ ## Original Source
28
+
29
+ - **Repository:** [gaussalgo/T5-LM-Large-text2sql-spider](https://huggingface.co/gaussalgo/T5-LM-Large-text2sql-spider)
30
+ - **Base model:** [google/t5-large-lm-adapt](https://huggingface.co/google/t5-large-lm-adapt)
31
+ - **License:** Apache 2.0
32
+
33
+ ## Usage with inference4j
34
+
35
+ ```java
36
+ try (var sqlGen = T5SqlGenerator.t5LargeSpider().build()) {
37
+ String sql = sqlGen.generateSql(
38
+ "How many employees are in each department?",
39
+ "\"employees\" \"id\" int, \"name\" varchar, \"dept_id\" int "
40
+ + "[SEP] \"departments\" \"id\" int, \"name\" varchar");
41
+ System.out.println(sql);
42
+ }
43
+ ```
44
+
45
+ ## Schema Format
46
+
47
+ The model expects the schema in the following format:
48
+
49
+ ```
50
+ "table_name" "col1" type, "col2" type, foreign_key: "table"."col" = "other"."col" primary key: "col" [SEP] "table2" ...
51
+ ```
52
+
53
+ - Table and column names are double-quoted
54
+ - Columns are comma-separated with types
55
+ - Tables are separated by `[SEP]`
56
+ - Foreign keys and primary keys are declared per table
57
+
58
+ ## Model Details
59
+
60
+ | Property | Value |
61
+ |----------|-------|
62
+ | Architecture | T5 encoder-decoder (0.8B parameters) |
63
+ | Task | Text-to-SQL generation |
64
+ | Training data | Spider, Spider-Syn |
65
+ | Tokenizer | SentencePiece (32,128 tokens) |
66
+ | Original framework | PyTorch (transformers) |
67
+ | Export method | Hugging Face Optimum (encoder-decoder with KV cache) |
68
+
69
+ ## License
70
+
71
+ This model is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). Original model by [Gaussalgo](https://huggingface.co/gaussalgo), base model by [Google](https://huggingface.co/google).
chat_template.jinja ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% if not add_generation_prompt is defined %}
2
+ {% set add_generation_prompt = false %}
3
+ {% endif %}
4
+ {%- set ns = namespace(found=false) -%}
5
+ {%- for message in messages -%}
6
+ {%- if message['role'] == 'system' -%}
7
+ {%- set ns.found = true -%}
8
+ {%- endif -%}
9
+ {%- endfor -%}
10
+ {{bos_token}}{%- if not ns.found -%}
11
+ {{'You are an AI programming assistant, utilizing the Deepseek Coder model, developed by Deepseek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer\n'}}
12
+ {%- endif %}
13
+ {%- for message in messages %}
14
+ {%- if message['role'] == 'system' %}
15
+ {{ message['content'] }}
16
+ {%- else %}
17
+ {%- if message['role'] == 'user' %}
18
+ {{'### Instruction:\n' + message['content'] + '\n'}}
19
+ {%- else %}
20
+ {{'### Response:\n' + message['content'] + '\n<|EOT|>\n'}}
21
+ {%- endif %}
22
+ {%- endif %}
23
+ {%- endfor %}
24
+ {% if add_generation_prompt %}
25
+ {{'### Response:'}}
26
+ {% endif %}
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "T5ForConditionalGeneration"
4
+ ],
5
+ "classifier_dropout": 0.0,
6
+ "d_ff": 2816,
7
+ "d_kv": 64,
8
+ "d_model": 1024,
9
+ "decoder_start_token_id": 0,
10
+ "dense_act_fn": "gelu_new",
11
+ "dropout_rate": 0.1,
12
+ "dtype": "float32",
13
+ "eos_token_id": 1,
14
+ "feed_forward_proj": "gated-gelu",
15
+ "initializer_factor": 1.0,
16
+ "is_encoder_decoder": true,
17
+ "is_gated_act": true,
18
+ "layer_norm_epsilon": 1e-06,
19
+ "model_type": "t5",
20
+ "num_decoder_layers": 24,
21
+ "num_heads": 16,
22
+ "num_layers": 24,
23
+ "output_past": true,
24
+ "pad_token_id": 0,
25
+ "relative_attention_max_distance": 128,
26
+ "relative_attention_num_buckets": 32,
27
+ "tie_word_embeddings": false,
28
+ "transformers_version": "4.57.6",
29
+ "use_cache": true,
30
+ "vocab_size": 32128
31
+ }
decoder_model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:352f7316dd381b1e326577aea0183f7e09852340f04c499b867c3c4a3896b398
3
+ size 1900001851
decoder_with_past_model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99afdd41369f574fc64b4d16d0ebdb291f44c64f2cfce71d0b8f0cb4c270c669
3
+ size 1698604355
encoder_model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4225eabda107b4eedf5ddb53ff860fc575a397a30764f228f589884ead46d076
3
+ size 1365296186
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff