Richard Neuschulz commited on
Commit
0e721c2
1 Parent(s): fdba93d

new approach

Browse files
Files changed (43) hide show
  1. README.md +1 -1
  2. app.py +29 -26
  3. config.json +0 -31
  4. generation_config.json +0 -6
  5. model-00001-of-00039.safetensors +0 -3
  6. model-00002-of-00039.safetensors +0 -3
  7. model-00003-of-00039.safetensors +0 -3
  8. model-00004-of-00039.safetensors +0 -3
  9. model-00005-of-00039.safetensors +0 -3
  10. model-00006-of-00039.safetensors +0 -3
  11. model-00007-of-00039.safetensors +0 -3
  12. model-00008-of-00039.safetensors +0 -3
  13. model-00009-of-00039.safetensors +0 -3
  14. model-00010-of-00039.safetensors +0 -3
  15. model-00011-of-00039.safetensors +0 -3
  16. model-00012-of-00039.safetensors +0 -3
  17. model-00013-of-00039.safetensors +0 -3
  18. model-00014-of-00039.safetensors +0 -3
  19. model-00015-of-00039.safetensors +0 -3
  20. model-00016-of-00039.safetensors +0 -3
  21. model-00017-of-00039.safetensors +0 -3
  22. model-00018-of-00039.safetensors +0 -3
  23. model-00019-of-00039.safetensors +0 -3
  24. model-00020-of-00039.safetensors +0 -3
  25. model-00021-of-00039.safetensors +0 -3
  26. model-00022-of-00039.safetensors +0 -3
  27. model-00023-of-00039.safetensors +0 -3
  28. model-00024-of-00039.safetensors +0 -3
  29. model-00025-of-00039.safetensors +0 -3
  30. model-00026-of-00039.safetensors +0 -3
  31. model-00027-of-00039.safetensors +0 -3
  32. model-00028-of-00039.safetensors +0 -3
  33. model-00029-of-00039.safetensors +0 -3
  34. model-00030-of-00039.safetensors +0 -3
  35. model-00031-of-00039.safetensors +0 -3
  36. model-00032-of-00039.safetensors +0 -3
  37. model-00033-of-00039.safetensors +0 -3
  38. model-00034-of-00039.safetensors +0 -3
  39. model-00035-of-00039.safetensors +0 -3
  40. model-00036-of-00039.safetensors +0 -3
  41. model-00037-of-00039.safetensors +0 -3
  42. model-00038-of-00039.safetensors +0 -3
  43. model-00039-of-00039.safetensors +0 -3
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: KafkaLM 8x7b German
3
- emoji: 🏴
4
  colorFrom: gray
5
  colorTo: yellow
6
  sdk: gradio
 
1
  ---
2
  title: KafkaLM 8x7b German
3
+ emoji: 🏴🍺
4
  colorFrom: gray
5
  colorTo: yellow
6
  sdk: gradio
app.py CHANGED
@@ -1,31 +1,34 @@
1
- from transformers import AutoModelForCausalLM, AutoTokenizer
 
2
 
 
3
  model_id = "seedboxai/KafkaLM-8x7B-German-V0.1-DPO"
4
-
5
- model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True, trust_remote_code=True)
6
-
7
  tokenizer = AutoTokenizer.from_pretrained(model_id)
 
8
 
9
- def generate_prompt(input):
10
- prompt = ''
11
- sys_prompt = "Du bist ein freundlicher und hilfsbereiter KI-Assistent. Du beantwortest Fragen faktenorientiert und präzise, ohne dabei relevante Fakten auszulassen."
 
12
 
13
- prompt += f"<|system|>\n{sys_prompt.strip()}</s>\n"
14
- prompt += f"<|user|>\n{input.strip()}</s>\n"
15
- prompt += f"<|assistant|>\n"
16
-
17
- return prompt.strip()
18
-
19
-
20
- generate_text = transformers.pipeline(
21
- model=model, tokenizer=tokenizer,
22
- return_full_text=True,
23
- task='text-generation',
24
- temperature=0.5,
25
- max_new_tokens=512,
26
- top_p=0.95,
27
- top_k=50,
28
- do_sample=True,
29
- )
30
-
31
- print(generate_text(generate_prompt("Wer ist eigentlich dieser Kafka?")))
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3
 
4
+ # Load the model and tokenizer from Hugging Face
5
  model_id = "seedboxai/KafkaLM-8x7B-German-V0.1-DPO"
 
 
 
6
  tokenizer = AutoTokenizer.from_pretrained(model_id)
7
+ model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True, trust_remote_code=True)
8
 
9
+ # Define the text generation function
10
+ def generate_text(user_input, system_prompt):
11
+ # Combine the system prompt and the user input to form the full prompt
12
+ full_prompt = f"{system_prompt.strip()}\n\n{user_input.strip()}"
13
 
14
+ # Initialize the pipeline for text generation
15
+ text_generator = pipeline('text-generation', model=model, tokenizer=tokenizer,
16
+ return_full_text=True, temperature=0.5,
17
+ max_new_tokens=512, top_p=0.95, top_k=50, do_sample=True)
18
+
19
+ # Generate text based on the full prompt
20
+ results = text_generator(full_prompt)
21
+ generated_text = results[0]['generated_text']
22
+
23
+ return generated_text
24
+
25
+ # Setup the Gradio interface
26
+ iface = gr.Interface(fn=generate_text,
27
+ inputs=[gr.Textbox(lines=2, label="User Prompt"), gr.Textbox(lines=5, label="System Prompt")],
28
+ outputs=gr.Textbox(label="Generated Text"),
29
+ title="Text Generation with KafkaLM",
30
+ description="Enter a user prompt and a system prompt to generate text using the KafkaLM model.")
31
+
32
+ # Launch the Gradio app
33
+ if __name__ == "__main__":
34
+ iface.launch()
config.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "_name_or_path": "/workspace/Mixtral-MoE-8x7B/mixtral_FT",
3
- "architectures": [
4
- "MixtralForCausalLM"
5
- ],
6
- "attention_dropout": 0.0,
7
- "bos_token_id": 1,
8
- "eos_token_id": 2,
9
- "hidden_act": "silu",
10
- "hidden_size": 4096,
11
- "initializer_range": 0.02,
12
- "intermediate_size": 14336,
13
- "max_position_embeddings": 32768,
14
- "model_type": "mixtral",
15
- "num_attention_heads": 32,
16
- "num_experts_per_tok": 2,
17
- "num_hidden_layers": 32,
18
- "num_key_value_heads": 8,
19
- "num_local_experts": 8,
20
- "output_router_logits": false,
21
- "rms_norm_eps": 1e-05,
22
- "rope_theta": 1000000.0,
23
- "router_aux_loss_coef": 0.02,
24
- "sliding_window": null,
25
- "tie_word_embeddings": false,
26
- "torch_dtype": "float32",
27
- "transformers_version": "4.38.0.dev0",
28
- "use_cache": true,
29
- "vocab_size": 32000
30
- }
31
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
generation_config.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "_from_model_config": true,
3
- "bos_token_id": 1,
4
- "eos_token_id": 2,
5
- "transformers_version": "4.38.0.dev0"
6
- }
 
 
 
 
 
 
 
model-00001-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5c990c6ea3bdfcde5d6fa97a20f7bb8489e8c7338644e2b22f8cf25818ce9e11
3
- size 4920052720
 
 
 
 
model-00002-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:fe7646c12dd730078c98f2d44297b44458307dd12767b467b4f86a2984f1de47
3
- size 4865559920
 
 
 
 
model-00003-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:13f19a49293abe99a576b0ce3929cc07ef41f27d0c9baaa3f52f68970b6720d4
3
- size 4865559920
 
 
 
 
model-00004-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d518bfaaaed4ab6745318fd3547c4a30ad8f5dc9ed3880e23597976d34c68554
3
- size 4865559920
 
 
 
 
model-00005-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:7cadcd62f958377f8c6ecd2a8d91789b39d947608ef5966dcbe1c4a1f47049d0
3
- size 4865559920
 
 
 
 
model-00006-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0db04d581cc8843ee905224a263c533aea2bc040df93ebd9e21f7485ea753132
3
- size 4932504264
 
 
 
 
model-00007-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ff5119411700efc0b0d80b0e7b364eddbfb9847f91c3296e0b344acd981fcbd2
3
- size 4865559912
 
 
 
 
model-00008-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f2d6314b97e43abad0e93d8fb3fdf2a1ff8dc7dd1e18d56abf07334ca1b56096
3
- size 4865559920
 
 
 
 
model-00009-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b83d7e18dfbcca682465e23367fcb93655e2d5fe60ff00371b49844cdeb98b8b
3
- size 4865559920
 
 
 
 
model-00010-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:040485aa8f9d4d146e0b248ddcf16d2593ab47a156f026543ba659783bee51d8
3
- size 4865559920
 
 
 
 
model-00011-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f9fda815c4e401d63794a75664e4454086808cada111685d56ccf9590e6fe54b
3
- size 4865559920
 
 
 
 
model-00012-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e7ac62fa7b4945beaa9aa2541df84b1b3df5cdce7d1af1accd308384ce7ddc9c
3
- size 4999646240
 
 
 
 
model-00013-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:41f87398271754733a0667682eb8ef4d211d1aab970ab86cff5bdca322f8a8df
3
- size 4798417968
 
 
 
 
model-00014-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b1c4e598453fdcc597b6291e8b4788b21cab23be4f1b806e0871ab4140680603
3
- size 4865559944
 
 
 
 
model-00015-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:eb037b28ce4cd25ae3f235c22a40735520ec542c14da4c335de353b6155e1835
3
- size 4865559944
 
 
 
 
model-00016-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0e2e178b8bedb7d402569aa1a1dbfa1fe3161944d2854b255eee94c73162015f
3
- size 4865559944
 
 
 
 
model-00017-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:76943d899f6924da8272f4cc50d02e8864de99158d355bc35f5ba0e8915a858e
3
- size 4865559944
 
 
 
 
model-00018-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:434c588897cde14211182cfd7d2eade857b0addd8c9c409655f72b1d005b910e
3
- size 4865559944
 
 
 
 
model-00019-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c5bdbc41a8f2386b2ecfb6ff9844e26deec4023ada34b3f2dd555506f5ef9d73
3
- size 4932504280
 
 
 
 
model-00020-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d58562d1f02dd718c7ed1da1fd0ca6f73c9e356cb3bffcc5d93106b61a9359a3
3
- size 4865559944
 
 
 
 
model-00021-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:26fab439fad7a239ae79a27dad2dbc7ca9ff1c35ffaad6c28922f7a1f91f81b2
3
- size 4865559944
 
 
 
 
model-00022-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f809057c08a390638024321e4c22d68c25dc5de15033bf875ccb4e3f807d1dd9
3
- size 4865559944
 
 
 
 
model-00023-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:24141d66049ad3723104e8f55a99b90afb2e1dfe74cf42919ae4ef4c8a117ee0
3
- size 4865559944
 
 
 
 
model-00024-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:25d5c910e8270ede8c48a189549fc8818e26913f1a7421ba02b5b95e8e4e22ee
3
- size 4865559944
 
 
 
 
model-00025-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:64dec72f25781d1370290a1a67c908fe326e6e088b544e5c3598810d25fa4160
3
- size 4932504280
 
 
 
 
model-00026-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f5c3a336a71bee7c2eb841c8a4a26b05ad034d691124108c7773b4b42809f0be
3
- size 4865559944
 
 
 
 
model-00027-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4878787645006ae7b52fd7c53bbb26ff450d0ebdd179292d0bc532b6586492d2
3
- size 4865559944
 
 
 
 
model-00028-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0b7b39c7adc025284ad8e514487ecd4939bafc7386ae9deea94c528970b145d8
3
- size 4865559944
 
 
 
 
model-00029-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:1e588bb3ca105a72e84a20e4230eb799e86539bd5e5e27009446af45ce139dff
3
- size 4865559944
 
 
 
 
model-00030-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:58294165ab3abb9ef2a73e7d93aaab5b638bdb419aae60249c50bd7deb088188
3
- size 4865559944
 
 
 
 
model-00031-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c14e641970ea2f713977d63036547814ccd243f2681352ec941570d9df17312a
3
- size 4932504280
 
 
 
 
model-00032-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2b2c94d4d9fd8996474fde5ff1b568fbbdafeb130c7a7027dd48acfbf2413274
3
- size 4865559944
 
 
 
 
model-00033-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:03f06fe39f9c0fa4dd8dd18894a9c54ffc0267a5b29c677c8fc65ce7d4542010
3
- size 4865559944
 
 
 
 
model-00034-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f241bf09bf2c482c01267eaca0d609ca76897ebb095f5811d17885bf376584b6
3
- size 4865559944
 
 
 
 
model-00035-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:7dc056901ca382f1411315fdb058f5e81d94c84891eccd84f52f7305b55ce2af
3
- size 4865559944
 
 
 
 
model-00036-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:906664c2b302d64f59ac8b77f1574f96b4a8e050fd30a127d57ef3af119a68a1
3
- size 4865559944
 
 
 
 
model-00037-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:57525a3d3d422788d35b394624fea656a5d8f7d1cc987d8377b7963bf006d34d
3
- size 4999646264
 
 
 
 
model-00038-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:1f6c9be67ffd7c39216759c94e4eb835ae455b9a1f15d3d2facd28a90774a0ce
3
- size 4798417968
 
 
 
 
model-00039-of-00039.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:cf35d1c660a0ff1e3715fafc0b3575c26e9ed2bc1a9ba618db23aaab1bd44cb2
3
- size 1463862216