commit
f7ab2caef0
|
@ -2,8 +2,15 @@ from transformers import BertForMaskedLM
|
||||||
model = BertForMaskedLM.from_pretrained("bert-base-cased")
|
model = BertForMaskedLM.from_pretrained("bert-base-cased")
|
||||||
# suppose we load BERT
|
# suppose we load BERT
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
port=True
|
||||||
|
else:
|
||||||
|
port=int(sys.argv[1])
|
||||||
|
|
||||||
from opendelta import LoraModel
|
from opendelta import LoraModel
|
||||||
delta_model = LoraModel(backbone_model=model, interactive_modify=True)
|
delta_model = LoraModel(backbone_model=model, interactive_modify=port)
|
||||||
# This will visualize the backbone after modification and other information.
|
# This will visualize the backbone after modification and other information.
|
||||||
|
|
||||||
delta_model.freeze_module(exclude=["deltas", "layernorm_embedding"], set_state_dict=True)
|
delta_model.freeze_module(exclude=["deltas", "layernorm_embedding"], set_state_dict=True)
|
||||||
|
|
|
@ -165,7 +165,7 @@ for (i = 0; i < coll.length; i++) {
|
||||||
var submit = document.getElementById("submit");
|
var submit = document.getElementById("submit");
|
||||||
submit.addEventListener("click", function() {
|
submit.addEventListener("click", function() {
|
||||||
const Http = new XMLHttpRequest();
|
const Http = new XMLHttpRequest();
|
||||||
const url='/submit/?name='+array.join(";");
|
const url='/submit/?name='+array.join("&name=");
|
||||||
Http.open("GET", url);
|
Http.open("GET", url);
|
||||||
Http.send();
|
Http.send();
|
||||||
alert("Now go back to your console")
|
alert("Now go back to your console")
|
||||||
|
|
|
@ -107,7 +107,7 @@ class hello:
|
||||||
class submit:
|
class submit:
|
||||||
def GET(self, _):
|
def GET(self, _):
|
||||||
global names
|
global names
|
||||||
names = [name.strip("root.") for name in web.input().name.split(";")]
|
names = [name[5:] for name in web.input(name=[]).name]
|
||||||
app.stop()
|
app.stop()
|
||||||
|
|
||||||
def interactive(model, port=8888):
|
def interactive(model, port=8888):
|
||||||
|
@ -120,7 +120,7 @@ def interactive(model, port=8888):
|
||||||
print("If on your machine, open the link below for interactive modification.\n "
|
print("If on your machine, open the link below for interactive modification.\n "
|
||||||
"If on remote host, you could use port mapping, "
|
"If on remote host, you could use port mapping, "
|
||||||
"or run in vscode terminal, which automatically do port mapping for you.")
|
"or run in vscode terminal, which automatically do port mapping for you.")
|
||||||
app.run()
|
app.run(port)
|
||||||
global names
|
global names
|
||||||
print("modified_modules:")
|
print("modified_modules:")
|
||||||
print(names)
|
print(names)
|
||||||
|
|
Loading…
Reference in New Issue