yunzi7 commited on
Commit
fcfe249
β€’
1 Parent(s): 4a329cb

load model

Browse files
.gitignore ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ # VSC config
132
+ .vscode/
133
+
134
+ # JetBrains config
135
+ .idea/
136
+
137
+ venv/
flask_session/2029240f6d1128be89ddc32729463129 CHANGED
Binary files a/flask_session/2029240f6d1128be89ddc32729463129 and b/flask_session/2029240f6d1128be89ddc32729463129 differ
 
flask_session/c9f52df6baf57fcc03af8634ade01a4c ADDED
Binary file (68 Bytes). View file
 
ice_breaking_challenge/__init__.py CHANGED
@@ -21,8 +21,10 @@ def create_app(test_config=None):
21
 
22
  # model loading
23
  # Kaggle API Key ν™˜κ²½ λ³€μˆ˜ μ„€μ •
24
- kaggle_username = os.getenv("KAGGLE_USERNAME")
25
- kaggle_key = os.getenv("KAGGLE_KEY")
 
 
26
  os.environ['KAGGLE_USERNAME'] = kaggle_username
27
  os.environ['KAGGLE_KEY'] = kaggle_key
28
  model = load_model_with_lora()
 
21
 
22
  # model loading
23
  # Kaggle API Key ν™˜κ²½ λ³€μˆ˜ μ„€μ •
24
+ # kaggle_username = os.getenv("KAGGLE_USERNAME")
25
+ kaggle_username = "yunzi7"
26
+ # kaggle_key = os.getenv("KAGGLE_KEY")
27
+ kaggle_key = "366492cccaf65572878ce8f77000e97a"
28
  os.environ['KAGGLE_USERNAME'] = kaggle_username
29
  os.environ['KAGGLE_KEY'] = kaggle_key
30
  model = load_model_with_lora()
ice_breaking_challenge/models/gemma2_it_2b_icebreaking.lora.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d054362a9d0ac80b58fb79e0de00ceadea5dd980f01420dc503329c5d3690fd
3
+ size 23576536
ice_breaking_challenge/models/model_loader.py CHANGED
@@ -1,7 +1,7 @@
1
  import keras_nlp
2
 
3
  MODEL_NAME = "gemma2_instruct_2b_en"
4
- LORA_WEIGHT_PATH = "weights/gemma2_it_2b_icebreaking.lora.h5"
5
 
6
  def load_model_with_lora(model_name:str = MODEL_NAME, lora_weight_path: str = LORA_WEIGHT_PATH):
7
  """
@@ -16,6 +16,42 @@ def load_model_with_lora(model_name:str = MODEL_NAME, lora_weight_path: str = LO
16
  """
17
  model = keras_nlp.models.GemmaCausalLM.from_preset(model_name)
18
 
 
19
  model.backbone.load_lora_weights(lora_weight_path)
 
 
 
 
 
 
20
 
21
  return model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import keras_nlp
2
 
3
  MODEL_NAME = "gemma2_instruct_2b_en"
4
+ LORA_WEIGHT_PATH = "ice_breaking_challenge/models/gemma2_it_2b_icebreaking.lora.h5"
5
 
6
  def load_model_with_lora(model_name:str = MODEL_NAME, lora_weight_path: str = LORA_WEIGHT_PATH):
7
  """
 
16
  """
17
  model = keras_nlp.models.GemmaCausalLM.from_preset(model_name)
18
 
19
+
20
  model.backbone.load_lora_weights(lora_weight_path)
21
+ question_crawling="λ‚˜μ˜ 이런 점은 일할 λ•Œ 도움이 돼!?"
22
+ answer_crawling="λ‚˜λˆ„κ³  μ‹Άμ–΄ν•˜λŠ” 마음? μ£Όλ³€ μ‚¬λžŒλ“€μ€ 그만 퍼주라고 ν•˜κΈ°λ„ ν•˜μ§€λ§Œ, λ‚΄κ°€ ν΄λΌμ΄μ–ΈνŠΈλ‘œλΆ€ν„° λˆμ„ 벌고자 ν•˜λŠ” 것이 μ•„λ‹ˆλΌ μ‘°κΈˆμ΄λΌλ„ 더 μ±™κ²¨μ£Όκ³ μž ν•˜λŠ” λ§ˆμŒμ„ κ°€μ‘Œμ„ λ•Œ κ²°κ΅­ λ‚˜μ˜ λΈŒλžœλ“œκ°€ 훨씬 더 컀질 수 μžˆλ‹€λŠ” 믿음이 μžˆλ‹€."
23
+
24
+ input_text = f"{question_crawling} {answer_crawling}"
25
+
26
+ print(model.generate(input_text, max_length=512))
27
 
28
  return model
29
+
30
+
31
+ # def template_setting(df:pd.DataFrame, is_test:bool) -> np.ndarray:
32
+ # template_input="""
33
+ # <instruction>
34
+ # Using the text: {question_crawling} {answer_crawling}, create a new multiple-choice question with 4 answer options.
35
+ # """
36
+
37
+ # template_output="""
38
+ # <Response>
39
+ # {question_generated}
40
+ # {multiple_choice_generated}
41
+ # {answer_generated}
42
+ # """
43
+ # template=template_input+'\n'+template_output
44
+
45
+ # inputs = np.array(df.apply(lambda row: template.format(
46
+ # question_crawling=row['question_crawling'],
47
+ # answer_crawling=row['answer_crawling'],
48
+ # question_generated=row['question_generated'] if not is_test else "",
49
+ # multiple_choice_generated=row['multiple_choice_generated'] if not is_test else "",
50
+ # answer_generated=row['answer_generated'] if not is_test else "").strip(), axis=1))
51
+
52
+ # outputs = np.array(df.apply(lambda row: template_output.format(
53
+ # question_generated=row['question_generated'],
54
+ # multiple_choice_generated=row['multiple_choice_generated'],
55
+ # answer_generated=row['answer_generated']).strip(), axis=1))
56
+ # combined_array = np.column_stack((inputs, outputs))
57
+ # return combined_array
ice_breaking_challenge/qr.py CHANGED
@@ -21,5 +21,4 @@ def qr() -> None:
21
  case "GET":
22
  return render_template("qr.html")
23
  case "POST": # qr.htmlμ—μ„œ `λ‹€μŒ` λ²„νŠΌ λˆŒλ €μ„ λ•Œ
24
- print("POST---------------------------------------")
25
  return render_template("introduction.html")
 
21
  case "GET":
22
  return render_template("qr.html")
23
  case "POST": # qr.htmlμ—μ„œ `λ‹€μŒ` λ²„νŠΌ λˆŒλ €μ„ λ•Œ
 
24
  return render_template("introduction.html")
requirements.txt CHANGED
@@ -1,3 +1,6 @@
1
  flask
2
  Flask-Session
3
- keras-nlp
 
 
 
 
1
  flask
2
  Flask-Session
3
+ tensorflow
4
+ keras
5
+ keras-nlp
6
+ tensorflow-text