Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/black #134

Closed
wants to merge 54 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
612c9eb
initial changes to hf miner
p-ferreira Jan 29, 2024
afe3993
adds 8bit and 4bit config
p-ferreira Jan 30, 2024
a424e6e
simplifies torch type logic
p-ferreira Jan 30, 2024
843f9a2
adapt zephyr miner to hf miner
p-ferreira Jan 30, 2024
e51ff26
update README for hf miner
p-ferreira Jan 30, 2024
65f3b74
adds should_force_model_loading flag to miners
p-ferreira Jan 30, 2024
1ae7540
miners module refactor
p-ferreira Jan 31, 2024
c2d40f6
runs black on miners code
p-ferreira Jan 31, 2024
9669cab
properly adds miner integration with system prompt args
p-ferreira Jan 31, 2024
dde3840
adds check verification on global logger definition
p-ferreira Feb 1, 2024
9b5b91f
clean main func from hf miner
p-ferreira Feb 1, 2024
a8e3bc8
refactor agent code + adds react agent
p-ferreira Feb 5, 2024
369820b
agents adjustments
p-ferreira Feb 5, 2024
53ca503
adds max iteration to agents
p-ferreira Feb 5, 2024
cc2b5c9
fix load llm issue
p-ferreira Feb 5, 2024
ce160ca
fix max tokens param
p-ferreira Feb 5, 2024
b8dd71b
adds toolminer for experiments
p-ferreira Feb 6, 2024
df7638b
fix error case for non wiki match
p-ferreira Feb 7, 2024
8dc340d
increase wiki retries and fix tool_miner bug
p-ferreira Feb 8, 2024
443f831
black
mccrindlebrian Feb 14, 2024
b7bdf0b
Merge branch 'main' into features/hf-miner
p-ferreira Feb 23, 2024
d1255aa
depreciation on agent miners
mccrindlebrian Feb 28, 2024
e94efae
merge main
mccrindlebrian Feb 28, 2024
46f798e
add depreciation to reqs
mccrindlebrian Feb 28, 2024
51de23f
add log_status
mccrindlebrian Feb 28, 2024
39d8ad0
change version to 1.1.2
mccrindlebrian Feb 28, 2024
860ec69
black
mccrindlebrian Feb 29, 2024
4b0d76f
add .DS_Store and test precommit hook
mccrindlebrian Mar 1, 2024
341a1a6
add .DS_Store and pre-commit hooks
mccrindlebrian Mar 1, 2024
9980b27
remove format
mccrindlebrian Mar 1, 2024
7624711
test precommit hook
mccrindlebrian Mar 1, 2024
6b3ac32
test precommit hook
mccrindlebrian Mar 1, 2024
08eee87
run the pre-commit as executable
mccrindlebrian Mar 1, 2024
e6ec30f
run the pre-commit as executable
mccrindlebrian Mar 1, 2024
b90c576
test new precommit script
mccrindlebrian Mar 1, 2024
dd50b52
add precommit setup to readme
mccrindlebrian Mar 1, 2024
cb529ee
Merge branch 'pre-staging' into features/hf-miner
p-ferreira Mar 1, 2024
493e7e4
Update prompting/miners/agents/react_agent.py
p-ferreira Mar 1, 2024
7226fa1
Update prompting/miners/openai_miner.py
p-ferreira Mar 1, 2024
6d34528
update docstring
p-ferreira Mar 1, 2024
70ab932
adds deprecation tags to all agent classes
p-ferreira Mar 1, 2024
1ad9571
Manually remove .DS_Store files
steffencruz Mar 1, 2024
41fd140
Remove .DS_Store in all directories
steffencruz Mar 1, 2024
9186c8b
fix flake8 warnings
p-ferreira Mar 1, 2024
7719a48
drops unnecessary run code for base miner
p-ferreira Mar 1, 2024
10fc0ce
Update prompting/miners/openai_miner.py
p-ferreira Mar 1, 2024
acba249
deprecates tool miner
p-ferreira Mar 1, 2024
cb99e73
Merge pull request #91 from opentensor/features/hf-miner
steffencruz Mar 1, 2024
d55e953
Update neuron.py
steffencruz Mar 6, 2024
01255d1
black entire repo
mccrindlebrian Mar 6, 2024
bf71611
Merge pull request #145 from opentensor/hotfix/black-pre-staging
steffencruz Mar 7, 2024
c72b1e4
Merge pull request #143 from opentensor/hotfix/fix-set-weights
mccrindlebrian Mar 7, 2024
45569db
move precommit script
mccrindlebrian Mar 7, 2024
b2b983a
Merge branch 'pre-staging' into features/black
steffencruz Mar 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adapt zephyr miner to hf miner
  • Loading branch information
p-ferreira committed Jan 30, 2024
commit 843f9a26426ca0235912a4d2cbca9c187788dec0
28 changes: 18 additions & 10 deletions neurons/miners/huggingface/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@

class HuggingFaceMiner(Miner):
"""
Base miner which runs zephyr (https://huggingface.co/HuggingFaceH4/zephyr-7b-beta)
This requires a GPU with at least 20GB of memory.
Base 🤗 Hugging Face miner, integrated with hf pipeline.
To run this miner from the project root directory:

python neurons/miners/zephyr/miner.py --wallet.name <wallet_name> --wallet.hotkey <wallet_hotkey> --subtensor.network <network> --netuid <netuid> --axon.port <port> --axon.external_port <port> --logging.debug True --neuron.model_id HuggingFaceH4/zephyr-7b-beta --neuron.system_prompt "Hello, I am a chatbot. I am here to help you with your questions." --neuron.max_tokens 64 --neuron.do_sample True --neuron.temperature 0.9 --neuron.top_k 50 --neuron.top_p 0.95 --wandb.on True --wandb.entity sn1 --wandb.project_name miners_experiments
python neurons/miners/huggingface/miner.py --wallet.name <wallet_name> --wallet.hotkey <wallet_hotkey> --neuron.model_id <model_id> --subtensor.network <network> --netuid <netuid> --axon.port <port> --axon.external_port <port> --logging.debug True --neuron.model_id HuggingFaceH4/zephyr-7b-beta --neuron.system_prompt "Hello, I am a chatbot. I am here to help you with your questions." --neuron.max_tokens 64 --neuron.do_sample True --neuron.temperature 0.9 --neuron.top_k 50 --neuron.top_p 0.95 --wandb.on True --wandb.entity sn1 --wandb.project_name miners_experiments
"""
@classmethod
def add_args(cls, parser: argparse.ArgumentParser):
Expand All @@ -49,27 +48,36 @@ def __init__(self, config=None):
super().__init__(config=config)

model_kwargs = None
if self.config.neuron.load_quantized:
bt.logging.info("Loading quantized model...")
if self.config.neuron.load_in_8bit:
bt.logging.info("Loading 8 bit quantized model...")
model_kwargs = dict(
torch_dtype=torch.float16,
load_in_8bit=True,
)

if self.config.neuron.load_in_4bit:
bt.logging.info("Loading 4 bit quantized model...")
model_kwargs = dict(
torch_dtype=torch.float32,
load_in_4bit=True,
)

if self.config.wandb.on:
self.identity_tags = ("hf_miner", )

if self.config.neuron.load_quantized:
self.identity_tags += ("8bits_quantization", )
if self.config.neuron.load_in_8bit:
self.identity_tags += ("8bit_quantization", )
elif self.config.neuron.load_in_4bit:
self.identity_tags += ("4bit_quantization", )

self.llm_pipeline = load_pipeline(
model_id=self.config.neuron.model_id,
torch_dtype=torch.float16,
model_id=self.config.neuron.model_id,
device=self.device,
mock=self.config.mock,
model_kwargs=model_kwargs,
)

self.model_id = self.config.neuron.model_id
self.system_prompt = "You are a friendly chatbot who always responds concisely and helpfully. You are honest about things you don't know."

async def forward(self, synapse: PromptingSynapse) -> PromptingSynapse:
Expand All @@ -92,7 +100,7 @@ async def forward(self, synapse: PromptingSynapse) -> PromptingSynapse:
bt.logging.debug(f"📧 Message received, forwarding synapse: {synapse}")

prompt = synapse.messages[-1]
bt.logging.debug(f"💬 Querying zephyr: {prompt}")
bt.logging.debug(f"💬 Querying {self.model_id}: {prompt}")

response = HuggingFaceLLM(
llm_pipeline=self.llm_pipeline,
Expand Down