Question Answering
Transformers
Safetensors
German
phi3
text-generation
Connect-Transport
Logics Software
German support chatbot
Deutscher KI Chatbot
Kundenservice Chatbot
Deutscher Chatbot
KI-Chatbots für Unternehmen
Chatbot for SMEs
Question-answering
QLoRA fine-tuning
LLM training
custom_code
text-generation-inference
Run this model with HF Jobs
Run logicssoftwaregmbh/logicsct-phi4 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/logicssoftwaregmbh/logicsct-phi4. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/logicssoftwaregmbh/logicsct-phi4 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use logicssoftwaregmbh/logicsct-phi4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use logicssoftwaregmbh/logicsct-phi4 with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "question-answering" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("question-answering", model="logicssoftwaregmbh/logicsct-phi4", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("logicssoftwaregmbh/logicsct-phi4", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("logicssoftwaregmbh/logicsct-phi4", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149---
license: mit
------license: mitlanguage:- debase_model:- microsoft/phi-4pipeline_tag: question-answeringtags:- Connect-Transport- Logics Software- German support chatbot- Deutscher KI Chatbot- Kundenservice Chatbot- Deutscher Chatbot- KI-Chatbots für Unternehmen- Chatbot for SMEs- Question-answering- QLoRA fine-tuning- LLM traininglibrary_name: transformers---
# Model Card for logicsct-phi4**logicsct-phi4** is a QLoRA 4-bit fine-tuned version of [microsoft/phi-4](https://huggingface.co/microsoft/phi-4). This model has been adapted with domain-specific knowledge to serve as a support chatbot for [**Connect-Transport**](https://www.logics-connect.de), our transport management system developed at Logics Software GmbH.
While tailored for our internal use, the training principles and techniques we employed can also be applied by others interested in developing their own chatbot assistants.
We are continuously evaluating and refining our models to enhance the performance of our support chatbot for Connect-Transport.
## Finding a Good Base Model – Proficient in German and Following InstructionsWe have evaluated over 70 models for basic technical instruction tasks in German. The evaluation was carried out manually by reviewing the responses to the following questions:
- Wie kann ich in Chrome machen dass meine Downloads immer am gleichen Ort gespeichert werden?- Wie kann ich in Outlook meine Mail Signatur anpassen und einen Link und Bild dort einfügen?
The best models according to our subjective rating scale (1 = poor, 5 = excellent) are:
5-Star Rating:- Big proprietary models such as OpenAI o1, OpenAI 4o and OpenAI o1-mini- Huge models: [deepseek-ai/DeepSeek-R1 (685B)](https://huggingface.co/deepseek-ai/DeepSeek-R1), [deepseek-ai/DeepSeek-V3 (685B)](https://huggingface.co/deepseek-ai/DeepSeek-V3) and [mistralai/Mistral-Large-Instruct-2411 (123B)](https://huggingface.co/mistralai/Mistral-Large-Instruct-2411)- Large models: [Nexusflow/Athene-V2-Chat (72.7B)](https://huggingface.co/Nexusflow/Athene-V2-Chat) and [nvidia/Llama-3.1-Nemotron-70B-Instruct (70.6B)](https://huggingface.co/nvidia/Llama-3.1-Nemotron-70B-Instruct)
4-Star Rating:- Huge models: [mistralai/Mixtral-8x22B-Instruct-v0.1 (141B)](https://huggingface.co/mistralai/Mixtral-8x22B-Instruct-v0.1), [alpindale/WizardLM-2-8x22B (141B)](https://huggingface.co/alpindale/WizardLM-2-8x22B) and [CohereForAI/c4ai-command-r-plus-08-2024 (104B)](https://huggingface.co/CohereForAI/c4ai-command-r-plus-08-2024)- Large models: [meta-llama/Llama-3.3-70B-Instruct (70.6B)](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct) and [NousResearch/Hermes-3-Llama-3.1-70B (70.6B)](https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-70B)- Big models: [mistralai/Mixtral-8x7B-Instruct-v0.1 (46.7B)](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1)- Medium-sized models: [google/gemma-2-27b (27.2B)](https://huggingface.co/google/gemma-2-27b) and [mistralai/Mistral-Small-Instruct-2409 (22.2B)](https://huggingface.co/mistralai/Mistral-Small-Instruct-2409)- **Small-Sized Models (Current Main Focus)**: - [microsoft/phi-4 (14.7B)](https://huggingface.co/microsoft/phi-4) - [mistralai/Mistral-Nemo-Instruct-2407 (12.2B)](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407)
Models rated 3 stars or lower are not listed here. We have tested dozens of models with fewer than 20B and 10B parameters, but most do not understand or speak German well enough or perform adequately in the context of answering support chatbot technical questions.
Some models also have smaller versions that are not listed above because they did not achieve a 4+ rating. Additionally, some models (e.g., Hermes 3) have larger versions available that are not included, as their performance relative to model size was not impressive, making their massive 405B versions less interesting for our purposes.
Given our goal of training, exporting, and running inference on our dedicated server hardware, we primarily focus on models with fewer than 20B parameters while comparing their performance with that of some larger models.
## How We Fine-Tune Our Base ModelDue to our small training dataset and GPU VRAM constraints, we exclusively use QLoRA fine-tuning. After testing our own scripts, we ultimately settled on [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory), which meets our needs for straightforward training, inference, and export functionality across a wide range of models.
### Training DataOur training data currently consists of approximately **220 prompt-response pairs** in a carefully curated dataset.
To collect this training data, we developed an internal web app for our employees. In this app:- Employees enter both a prompt and a response — each pair forms a single training record.- Gamification is implemented via daily and weekly high score systems that highlight the employee who contributes the most training data.- The web app is also connected to a selection of current evaluation models to facilitate internal testing of how the models respond both to prompts from the training data and to new prompts.
Here are three example records of our training data:> Prompt: "Wie kann ich eine Tour umbenennen?"> <br>Response: "1. Öffnen Sie die Stoppliste der Tour und klicken Sie auf das Tourmenü (graues Zahnradsymbol ⚙️) rechts oben in der Stoppliste.\n2. Wählen Sie im Tourmenü \"Tour umbenennen\".\n3. Folgen Sie der Anweisung im Dialog und klicken Sie auf \"OK\".\nBeachten Sie: Fahrer können die Tour nicht umbenennen, sondern nur ein Disponent (Admin Account)."> <br>Prompt: "Wie werden Daten in Connect-Transport importiert?"> <br>Response: "Der Flex Importer liest Auftragsdaten aus Excel-Dateien ein. Alternativ können Daten per Schnittstelle direkt aus ERP- oder Warenwirtschaftssystemen importiert werden."> <br>Prompt: "Gibt es eine Möglichkeit zur Sendungsverfolgung für Endkunden?"> <br>Response: "Ja, mit dem Avisierungs-Modul können Disponenten per SMS oder E-Mail voraussichtliche Lieferzeiten an Empfänger senden, die ihre Sendungen live verfolgen können."
### QLoRA SettingsFull settings for `logicsct_train_Phi4_qlora_sft_otfq.yaml`:```### modelmodel_name_or_path: microsoft/phi-4quantization_bit: 4quantization_method: bitsandbytestrust_remote_code: true
### methodstage: sftdo_train: truefinetuning_type: loralora_rank: 128 # we still experiment with that#lora_alpha # default lora_rank * 2lora_target: all
### datasetdataset: logicscttemplate: phi4cutoff_len: 512overwrite_cache: truepreprocessing_num_workers: 16
### outputoutput_dir: saves/logicsct-phi4/lora/sftlogging_steps: 10save_steps: 500plot_loss: trueoverwrite_output_dir: true
### trainper_device_train_batch_size: 1gradient_accumulation_steps: 8learning_rate: 2.0e-4 # we still experiment with thatnum_train_epochs: 4.0 # we still experiment with thatlr_scheduler_type: cosinewarmup_ratio: 0.1bf16: trueddp_timeout: 180000000
### evalval_size: 0.2 # use 20% of dataset as the validation split.per_device_eval_batch_size: 1 # Keeps the evaluation batch size at 1 per deviceeval_strategy: steps # or "epoch" if you prefer evaluating at the end of each epocheval_steps: 500 # adjust this if needed (e.g., if you use "steps", it determines evaluation frequency)```
### Training, Inference, and ExportWe follow the instructions provided in the [LLaMA-Factory Quickstart Guide](https://github.com/hiyouga/LLaMA-Factory?tab=readme-ov-file#quickstart):
```llamafactory-cli train logicsct_train_Phi4_qlora_sft_otfq.yaml # VRAM used: 11093MiB for 4 bit QLoRA trainingllamafactory-cli chat logicsct_inference_Phi4_qlora_sft_otfq.yaml # VRAM used: 30927MiB for inference of base model + QLoRA adapterllamafactory-cli export logicsct_export_Phi4_qlora_sft.yaml # VRAM used: 665MiB + about 29 GB of system RAM for exporting a merged verison of the model with its adapterllamafactory-cli export logicsct_export_Phi4_qlora_sft_Q4.yaml # VRAM used: 38277MiB for a 4bit quant export of the merged modelllamafactory-cli chat logicsct_inference_Phi4_qlora_sft_otfq_Q4.yaml # VRAM used: 9255MiB-11405MiB VRAM for inference of the 4bit quant merged model (increasing with increasing context length)```
### Comparison of Open Source Training/Models with OpenAI Proprietary Fine-TuningWe have fine-tuned both OpenAI GPT 4o and 4o-mini and compared their performance to that of our best small-sized models. After some initial runs with unsatisfactory results, we significantly adjusted the hyperparameters and focused primarily on experimenting with 4o-mini.
With our current training data, both 4o and 4o-mini appear to require 5 epochs using the default learning rate, with the training loss approaching zero. With fewer epochs, however, the models seem not to learn sufficiently—perhaps due to the small size of our training dataset. Significant overfitting occurs at approximately 7 epochs for both models.
Our best settings so far are: - Epochs: 5 - Batch Size: 3 - Learning Rate: Automatically determined
Currently, our small-sized open-source models perform comparably to or even better than the fine-tuned 4o-mini. We will continue testing with OpenAI fine-tuning once we have a larger training dataset.
## Next StepsOur top priority at the moment is to collect more training data.README.md+149-3