eclfe commited on
Commit
171b9e7
·
verified ·
1 Parent(s): 114b213

Upload samplesqlenuse.ipynb

Browse files
Files changed (1) hide show
  1. samplesqlenuse.ipynb +114 -0
samplesqlenuse.ipynb ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 9,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "# Use a pipeline as a high-level helper\n",
10
+ "from transformers import pipeline"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 10,
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "\n",
20
+ "prompt = [\n",
21
+ " {\"role\": \"user\", \"content\": \"\"\" \"SELECT CITYalias0.CITY_NAME FROM CITY AS CITYalias0 WHERE CITYalias0.POPULATION = ( SELECT MAX( CITYalias1.POPULATION ) FROM CITY AS CITYalias1 WHERE CITYalias1.STATE_NAME = \\\"state_name0\\\" ) AND CITYalias0.STATE_NAME = \\\"state_name0\\\" ;\"\"\"},\n",
22
+ "]"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": 11,
28
+ "metadata": {},
29
+ "outputs": [
30
+ {
31
+ "name": "stderr",
32
+ "output_type": "stream",
33
+ "text": [
34
+ "c:\\Users\\eclal\\OneDrive\\Desktop\\VSCode\\.conda\\Lib\\site-packages\\transformers\\models\\mistral\\modeling_mistral.py:674: UserWarning: 1Torch was not compiled with flash attention. (Triggered internally at ..\\aten\\src\\ATen\\native\\transformers\\cuda\\sdp_utils.cpp:455.)\n",
35
+ " attn_output = torch.nn.functional.scaled_dot_product_attention(\n"
36
+ ]
37
+ },
38
+ {
39
+ "data": {
40
+ "text/plain": [
41
+ "[{'generated_text': [{'role': 'user',\n",
42
+ " 'content': ' \"SELECT CITYalias0.CITY_NAME FROM CITY AS CITYalias0 WHERE CITYalias0.POPULATION = ( SELECT MAX( CITYalias1.POPULATION ) FROM CITY AS CITYalias1 WHERE CITYalias1.STATE_NAME = \"state_name0\" ) AND CITYalias0.STATE_NAME = \"state_name0\" ;'},\n",
43
+ " {'role': 'assistant',\n",
44
+ " 'content': 'return me the city with the highest population in \" state_name0 \".\"'}]}]"
45
+ ]
46
+ },
47
+ "execution_count": 11,
48
+ "metadata": {},
49
+ "output_type": "execute_result"
50
+ }
51
+ ],
52
+ "source": [
53
+ "generate_text = pipeline(\n",
54
+ " model=\"eclfe/sqlen-1-21\",\n",
55
+ " torch_dtype=\"auto\",\n",
56
+ " trust_remote_code=True,\n",
57
+ " device_map={\"\": \"cuda:0\"},\n",
58
+ " token=True,\n",
59
+ ")\n",
60
+ "generate_text(prompt, renormalize_logits=True)"
61
+ ]
62
+ },
63
+ {
64
+ "cell_type": "code",
65
+ "execution_count": 12,
66
+ "metadata": {},
67
+ "outputs": [
68
+ {
69
+ "data": {
70
+ "text/plain": [
71
+ "[{'generated_text': [{'role': 'user',\n",
72
+ " 'content': ' \"SELECT CITYalias0.CITY_NAME FROM CITY AS CITYalias0 WHERE CITYalias0.POPULATION = ( SELECT MAX( CITYalias1.POPULATION ) FROM CITY AS CITYalias1 WHERE CITYalias1.STATE_NAME = \"state_name0\" ) AND CITYalias0.STATE_NAME = \"state_name0\" ;'},\n",
73
+ " {'role': 'assistant',\n",
74
+ " 'content': 'return me the city with the highest population in \" state_name0 \".\"'}]}]"
75
+ ]
76
+ },
77
+ "execution_count": 12,
78
+ "metadata": {},
79
+ "output_type": "execute_result"
80
+ }
81
+ ],
82
+ "source": [
83
+ "\n",
84
+ "\n",
85
+ "prompt = [\n",
86
+ " {\"role\": \"user\", \"content\": \"\"\" \"SELECT CITYalias0.CITY_NAME FROM CITY AS CITYalias0 WHERE CITYalias0.POPULATION = ( SELECT MAX( CITYalias1.POPULATION ) FROM CITY AS CITYalias1 WHERE CITYalias1.STATE_NAME = \\\"state_name0\\\" ) AND CITYalias0.STATE_NAME = \\\"state_name0\\\" ;\"\"\"},\n",
87
+ "]\n",
88
+ "pipe = pipeline(\"text-generation\", model=\"eclfe/sqlen-1-21\")\n",
89
+ "pipe(prompt)"
90
+ ]
91
+ }
92
+ ],
93
+ "metadata": {
94
+ "kernelspec": {
95
+ "display_name": "Python 3",
96
+ "language": "python",
97
+ "name": "python3"
98
+ },
99
+ "language_info": {
100
+ "codemirror_mode": {
101
+ "name": "ipython",
102
+ "version": 3
103
+ },
104
+ "file_extension": ".py",
105
+ "mimetype": "text/x-python",
106
+ "name": "python",
107
+ "nbconvert_exporter": "python",
108
+ "pygments_lexer": "ipython3",
109
+ "version": "3.12.4"
110
+ }
111
+ },
112
+ "nbformat": 4,
113
+ "nbformat_minor": 2
114
+ }