Skip to content

Instantly share code, notes, and snippets.

@Ron-Lavi
Last active March 6, 2024 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ron-Lavi/13ed4f3696f5b6cfd9607bc64371c442 to your computer and use it in GitHub Desktop.
Save Ron-Lavi/13ed4f3696f5b6cfd9607bc64371c442 to your computer and use it in GitHub Desktop.
Using localGPT with Mistral to ingest Foreman Docs
[rlavi@toolbox localGPT]$ python3 ingest.py --device_type cpu
2024-03-06 06:36:46,062 - INFO - ingest.py:147 - Loading documents from /home/rlavi/src/localGPT/SOURCE_DOCUMENTS
Importing: Administering Foreman.pdf
Importing: Planning for Foreman.pdf
Importing: Provisioning Hosts.pdf
Importing: Managing Hosts.pdf
Importing: Managing Security Compliance.pdf
Importing: Deploying Hosts using Application Centric Approach.pdf
Importing: Monitoring Foreman Performance.pdf
Importing: Managing Content.pdf
Importing: Configuring Hosts Using Ansible.pdf
Importing: Configuring Hosts Using Puppet.pdf
2024-03-06 06:36:46,097 - INFO - ingest.py:47 - Loading document batch
/home/rlavi/src/localGPT/SOURCE_DOCUMENTS/Administering Foreman.pdf loaded.

2024-03-06 06:36:46,097 - INFO - ingest.py:47 - Loading document batch
2024-03-06 06:36:46,097 - INFO - ingest.py:47 - Loading document batch
2024-03-06 06:36:46,098 - INFO - ingest.py:47 - Loading document batch
2024-03-06 06:36:46,098 - INFO - ingest.py:47 - Loading document batch
2024-03-06 06:36:46,098 - INFO - ingest.py:47 - Loading document batch
2024-03-06 06:36:46,098 - INFO - ingest.py:47 - Loading document batch
2024-03-06 06:36:46,098 - INFO - ingest.py:47 - Loading document batch
/home/rlavi/src/localGPT/SOURCE_DOCUMENTS/Provisioning Hosts.pdf loaded.
/home/rlavi/src/localGPT/SOURCE_DOCUMENTS/Planning for Foreman.pdf loaded.


/home/rlavi/src/localGPT/SOURCE_DOCUMENTS/Managing Hosts.pdf loaded.

/home/rlavi/src/localGPT/SOURCE_DOCUMENTS/Managing Security Compliance.pdf loaded.

/home/rlavi/src/localGPT/SOURCE_DOCUMENTS/Deploying Hosts using Application Centric Approach.pdf loaded.

/home/rlavi/src/localGPT/SOURCE_DOCUMENTS/Monitoring Foreman Performance.pdf loaded.

/home/rlavi/src/localGPT/SOURCE_DOCUMENTS/Managing Content.pdf loaded.

2024-03-06 06:36:50,554 - INFO - __init__.py:13 - pikepdf C++ to Python logger bridge initialized
2024-03-06 06:36:50,558 - INFO - __init__.py:13 - pikepdf C++ to Python logger bridge initialized
2024-03-06 06:36:50,558 - INFO - __init__.py:13 - pikepdf C++ to Python logger bridge initialized
2024-03-06 06:36:50,565 - INFO - __init__.py:13 - pikepdf C++ to Python logger bridge initialized
2024-03-06 06:36:50,573 - INFO - __init__.py:13 - pikepdf C++ to Python logger bridge initialized
2024-03-06 06:36:50,579 - INFO - __init__.py:13 - pikepdf C++ to Python logger bridge initialized
2024-03-06 06:36:50,622 - INFO - __init__.py:13 - pikepdf C++ to Python logger bridge initialized
2024-03-06 06:36:50,691 - INFO - __init__.py:13 - pikepdf C++ to Python logger bridge initialized
2024-03-06 06:36:56,334 - INFO - ingest.py:47 - Loading document batch
/home/rlavi/src/localGPT/SOURCE_DOCUMENTS/Configuring Hosts Using Ansible.pdf loaded.

2024-03-06 06:36:57,607 - INFO - ingest.py:47 - Loading document batch
/home/rlavi/src/localGPT/SOURCE_DOCUMENTS/Configuring Hosts Using Puppet.pdf loaded.

2024-03-06 06:37:16,462 - INFO - ingest.py:156 - Loaded 10 documents from /home/rlavi/src/localGPT/SOURCE_DOCUMENTS
2024-03-06 06:37:16,462 - INFO - ingest.py:157 - Split into 1679 chunks of text
2024-03-06 06:37:17,445 - INFO - SentenceTransformer.py:66 - Load pretrained SentenceTransformer: hkunlp/instructor-large
load INSTRUCTOR_Transformer
/home/rlavi/.local/lib/python3.11/site-packages/torch/_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly.  To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()
  return self.fget.__get__(instance, owner)()
max_seq_length  512
2024-03-06 06:37:18,605 - INFO - ingest.py:168 - Loaded embeddings from hkunlp/instructor-large
</details>
<details>
<summary>[rlavi@toolbox localGPT]$ python3 run_localGPT.py --model_type mistral --device_type cpu</summary>
<br>
2024-03-06 09:10:12,087 - INFO - run_localGPT.py:244 - Running on: cpu
2024-03-06 09:10:12,087 - INFO - run_localGPT.py:245 - Display Source Documents set to: False
2024-03-06 09:10:12,087 - INFO - run_localGPT.py:246 - Use history set to: False
2024-03-06 09:10:12,242 - INFO - SentenceTransformer.py:66 - Load pretrained SentenceTransformer: hkunlp/instructor-large
load INSTRUCTOR_Transformer
/home/rlavi/.local/lib/python3.11/site-packages/torch/_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly.  To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()
  return self.fget.__get__(instance, owner)()
max_seq_length  512
2024-03-06 09:10:13,105 - INFO - run_localGPT.py:132 - Loaded embeddings from hkunlp/instructor-large
2024-03-06 09:10:13,184 - INFO - run_localGPT.py:60 - Loading Model: TheBloke/Llama-2-7b-Chat-GGUF, on: cpu
2024-03-06 09:10:13,185 - INFO - run_localGPT.py:61 - This action can take a few minutes!
2024-03-06 09:10:13,185 - INFO - load_models.py:38 - Using Llamacpp for GGUF/GGML quantized models
llama_model_loader: loaded meta data with 19 key-value pairs and 291 tensors from ./models/models--TheBloke--Llama-2-7b-Chat-GGUF/snapshots/191239b3e26b2882fb562ffccdd1cf0f65402adb/llama-2-7b-chat.Q4_K_M.gguf (version GGUF V2)
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv   0:                       general.architecture str              = llama
llama_model_loader: - kv   1:                               general.name str              = LLaMA v2
llama_model_loader: - kv   2:                       llama.context_length u32              = 4096
llama_model_loader: - kv   3:                     llama.embedding_length u32              = 4096
llama_model_loader: - kv   4:                          llama.block_count u32              = 32
llama_model_loader: - kv   5:                  llama.feed_forward_length u32              = 11008
llama_model_loader: - kv   6:                 llama.rope.dimension_count u32              = 128
llama_model_loader: - kv   7:                 llama.attention.head_count u32              = 32
llama_model_loader: - kv   8:              llama.attention.head_count_kv u32              = 32
llama_model_loader: - kv   9:     llama.attention.layer_norm_rms_epsilon f32              = 0.000001
llama_model_loader: - kv  10:                          general.file_type u32              = 15
llama_model_loader: - kv  11:                       tokenizer.ggml.model str              = llama
llama_model_loader: - kv  12:                      tokenizer.ggml.tokens arr[str,32000]   = ["<unk>", "<s>", "</s>", "<0x00>", "<...
llama_model_loader: - kv  13:                      tokenizer.ggml.scores arr[f32,32000]   = [0.000000, 0.000000, 0.000000, 0.0000...
llama_model_loader: - kv  14:                  tokenizer.ggml.token_type arr[i32,32000]   = [2, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, ...
llama_model_loader: - kv  15:                tokenizer.ggml.bos_token_id u32              = 1
llama_model_loader: - kv  16:                tokenizer.ggml.eos_token_id u32              = 2
llama_model_loader: - kv  17:            tokenizer.ggml.unknown_token_id u32              = 0
llama_model_loader: - kv  18:               general.quantization_version u32              = 2
llama_model_loader: - type  f32:   65 tensors
llama_model_loader: - type q4_K:  193 tensors
llama_model_loader: - type q6_K:   33 tensors
llm_load_vocab: special tokens definition check successful ( 259/32000 ).
llm_load_print_meta: format           = GGUF V2
llm_load_print_meta: arch             = llama
llm_load_print_meta: vocab type       = SPM
llm_load_print_meta: n_vocab          = 32000
llm_load_print_meta: n_merges         = 0
llm_load_print_meta: n_ctx_train      = 4096
llm_load_print_meta: n_embd           = 4096
llm_load_print_meta: n_head           = 32
llm_load_print_meta: n_head_kv        = 32
llm_load_print_meta: n_layer          = 32
llm_load_print_meta: n_rot            = 128
llm_load_print_meta: n_embd_head_k    = 128
llm_load_print_meta: n_embd_head_v    = 128
llm_load_print_meta: n_gqa            = 1
llm_load_print_meta: n_embd_k_gqa     = 4096
llm_load_print_meta: n_embd_v_gqa     = 4096
llm_load_print_meta: f_norm_eps       = 0.0e+00
llm_load_print_meta: f_norm_rms_eps   = 1.0e-06
llm_load_print_meta: f_clamp_kqv      = 0.0e+00
llm_load_print_meta: f_max_alibi_bias = 0.0e+00
llm_load_print_meta: n_ff             = 11008
llm_load_print_meta: n_expert         = 0
llm_load_print_meta: n_expert_used    = 0
llm_load_print_meta: pooling type     = 0
llm_load_print_meta: rope type        = 0
llm_load_print_meta: rope scaling     = linear
llm_load_print_meta: freq_base_train  = 10000.0
llm_load_print_meta: freq_scale_train = 1
llm_load_print_meta: n_yarn_orig_ctx  = 4096
llm_load_print_meta: rope_finetuned   = unknown
llm_load_print_meta: model type       = 7B
llm_load_print_meta: model ftype      = Q4_K - Medium
llm_load_print_meta: model params     = 6.74 B
llm_load_print_meta: model size       = 3.80 GiB (4.84 BPW) 
llm_load_print_meta: general.name     = LLaMA v2
llm_load_print_meta: BOS token        = 1 '<s>'
llm_load_print_meta: EOS token        = 2 '</s>'
llm_load_print_meta: UNK token        = 0 '<unk>'
llm_load_print_meta: LF token         = 13 '<0x0A>'
llm_load_tensors: ggml ctx size =    0.11 MiB
llm_load_tensors:        CPU buffer size =  3891.24 MiB
..................................................................................................
llama_new_context_with_model: n_ctx      = 4096
llama_new_context_with_model: freq_base  = 10000.0
llama_new_context_with_model: freq_scale = 1
llama_kv_cache_init:        CPU KV buffer size =  2048.00 MiB
llama_new_context_with_model: KV self size  = 2048.00 MiB, K (f16): 1024.00 MiB, V (f16): 1024.00 MiB
llama_new_context_with_model:        CPU input buffer size   =    17.04 MiB
llama_new_context_with_model:        CPU compute buffer size =   288.00 MiB
llama_new_context_with_model: graph splits (measure): 1
AVX = 1 | AVX_VNNI = 0 | AVX2 = 1 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 1 | NEON = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | MATMUL_INT8 = 0 | 
Model metadata: {'tokenizer.ggml.unknown_token_id': '0', 'tokenizer.ggml.eos_token_id': '2', 'general.architecture': 'llama', 'llama.context_length': '4096', 'general.name': 'LLaMA v2', 'llama.embedding_length': '4096', 'llama.feed_forward_length': '11008', 'llama.attention.layer_norm_rms_epsilon': '0.000001', 'llama.rope.dimension_count': '128', 'llama.attention.head_count': '32', 'tokenizer.ggml.bos_token_id': '1', 'llama.block_count': '32', 'llama.attention.head_count_kv': '32', 'general.quantization_version': '2', 'tokenizer.ggml.model': 'llama', 'general.file_type': '15'}
Using fallback chat format: None
Enter a query: Can you explain what is the Foreman project and why should I use it?
Llama.generate: prefix-match hit

llama_print_timings:        load time =   56665.22 ms
llama_print_timings:      sample time =     298.50 ms /   463 runs   (    0.64 ms per token,  1551.07 tokens per second)
llama_print_timings: prompt eval time =  135399.38 ms /  1111 tokens (  121.87 ms per token,     8.21 tokens per second)
llama_print_timings:        eval time =  150423.48 ms /   462 runs   (  325.59 ms per token,     3.07 tokens per second)
llama_print_timings:       total time =  288132.25 ms /  1573 tokens

  
 
> Question:
Can you explain what is the Foreman project and why should I use it?


> Answer:
Of course! The Foreman project is an open-source project that provides tools and services for managing and deploying infrastructure as code (IaC). It allows you to define your infrastructure setup in a declarative format, using templates or Ansible playbooks, and manage it through a web UI or command-line interface (CLI).
Here are some reasons why you might want to use Foreman:
1. Version control: Foreman allows you to version control your infrastructure setup, so you can easily roll back changes if something goes wrong or collaborate with others on your infrastructure setup.
2. Consistency: Foreman ensures that your infrastructure is consistent across different environments, such as development, staging, and production, so you can easily deploy changes across these environments.
3. Reusability: Foreman allows you to define reusable infrastructure templates that can be used across different projects and environments, so you don't have to start from scratch every time you set up a new environment.
4. Automation: Foreman provides an API that can be used to automate the deployment of infrastructure, so you can automate tasks such as provisioning virtual machines or deploying applications.
5. Integration: Foreman integrates with other tools such as Ansible, Puppet, or OpenSCAP, so you can use these tools to manage your infrastructure in addition to Foreman.
6. Security: Foreman provides features such as access control and auditing, so you can ensure that only authorized users have access to your infrastructure and track changes to your infrastructure over time.
7. Scalability: Foreman is designed to scale horizontally, so it can handle large environments with many hosts and resources.
8. Ease of use: Foreman provides a web UI and CLI interface that is easy to use and intuitive, so you can quickly set up and manage your infrastructure without needing extensive technical knowledge.
In summary, Foreman provides a powerful toolset for managing and deploying infrastructure as code, making it easier to version control, automate, integrate with other tools, and ensure security and scalability in your infrastructure setup.
Enter a query: Thank you! What is Hammer used for?
Llama.generate: prefix-match hit

llama_print_timings:        load time =   56665.22 ms
llama_print_timings:      sample time =     142.93 ms /   218 runs   (    0.66 ms per token,  1525.28 tokens per second)
llama_print_timings: prompt eval time =  145341.57 ms /  1085 tokens (  133.96 ms per token,     7.47 tokens per second)
llama_print_timings:        eval time =   70975.49 ms /   217 runs   (  327.08 ms per token,     3.06 tokens per second)
llama_print_timings:       total time =  217399.98 ms /  1302 tokens


> Question:
Thank you! What is Hammer used for?

> Answer:
  Great! Hammer is used to execute remote commands on your Foreman server. Specifically, it is used to create, modify, and manage job templates, as well as execute jobs using those templates. Additionally, Hammer provides an interface for creating shell scripts based on Hammer commands for basic task automation, redirecting output from Hammer to other tools, and testing API responses using the `--debug` option.
To issue Hammer commands, a user must have access to your Foreman server and be able to log in to the Foreman web UI. Some features may not be available in Hammer compared to the Foreman web UI, as Hammer is focused on providing a CLI interface for managing your Foreman server.
Hammer can be used to create job templates with advanced settings, such as specifying an SSH user for connecting to the host, an effective user for executing the job, a description template for the job, and timeouts for killing or canceling the job. Hammer can also be used to synchronize products across multiple environments and organizations.


Enter a query: Can you explain what is Katello?
 
llama_print_timings:        load time =   66160.66 ms
llama_print_timings:      sample time =     243.59 ms /   378 runs   (    0.64 ms per token,  1551.82 tokens per second)
llama_print_timings: prompt eval time =  166638.25 ms /  1226 tokens (  135.92 ms per token,     7.36 tokens per second)
llama_print_timings:        eval time =  124822.46 ms /   377 runs   (  331.09 ms per token,     3.02 tokens per second)
llama_print_timings:       total time =  293311.27 ms /  1603 tokens


> Question:
Can you explain what is Katello?

> Answer:
  Certainly! Katello is an open-source platform designed to help organizations manage and streamline their software packages across various environments, including virtual machines, bare-metal servers, and containers. It provides a centralized repository for managing packages, configurations, and other artifacts required for application delivery.
Katello offers several features, including:
1. Package management: Katello enables users to manage packages across different environments, including virtual machines, bare-metal servers, and containers. It provides a unified repository for managing packages, making it easier to keep track of dependencies and configurations.
2. Content view management: Katello allows users to create content views, which act as repositories for packages and configurations. Content views can be used to group related packages and configurations together, making it easier to manage and deploy applications.
3. Publishing: Katello enables users to publish content views to various environments, such as virtual machines, bare-metal servers, or containers. This makes it easier to deploy applications across different environments without having to manually package or configure each environment separately.
4. Remote execution: Katello provides a remote execution engine that enables users to run scripts or commands on remote hosts from within the Katello console. This makes it easier to automate tasks such as package installation or configuration management across multiple environments.
5. Reporting: Katello offers reporting features that enable users to generate reports on package usage, configuration, or other metrics. These reports can be used to gain insights into application usage and performance across different environments.
Overall, Katello is designed to provide a centralized platform for managing software packages and configurations across various environments. It offers a range of features that make it easier to automate application delivery, deployment, and management tasks, while also providing visibility into application usage and performance.

Enter a query: Can you expain how can I convert a CentOS machine to Red Hat Enterprise Linux with Foreman?
Llama.generate: prefix-match hit

llama_print_timings:        load time =   66160.66 ms
llama_print_timings:      sample time =     402.98 ms /   620 runs   (    0.65 ms per token,  1538.55 tokens per second)
llama_print_timings: prompt eval time =  129791.52 ms /  1044 tokens (  124.32 ms per token,     8.04 tokens per second)
llama_print_timings:        eval time =  207171.68 ms /   619 runs   (  334.69 ms per token,     2.99 tokens per second)
llama_print_timings:       total time =  340234.44 ms /  1663 tokens


> Question:
Can you expain how can I convert a CentOS machine to Red Hat Enterprise Linux with Foreman?

> Answer:
  Certainly! To convert a CentOS machine to Red Hat Enterprise Linux (RHEL) using Foreman, you can follow these steps:
1. Prepare for the conversion: Before starting the conversion process, make sure you have completed the steps outlined in the Red Hat documentation for preparing for a RHEL conversion (<https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/converting_from_an_rpm-based_linux_distribution_to_rhel/index#proc_preparing-for-a-rhel-conversion_converting-using-the-command-line>). This includes uploading a subscription manifest to Foreman and ensuring that there are sufficient Red Hat Enterprise Linux entitlements allocated for the conversion.
2. Convert using Convert2RHEL: Once you have prepared your system, you can use the Convert2RHEL utility in Foreman to convert your CentOS machine to RHEL. This utility removes unnecessary packages, replaces the CentOS-release or Oracle-release package with the rhel-release package, and subscribes the host to Foreman community Subscription Management. The duration of the conversion process depends on various factors, including the number of packages that need to be replaced, network speed, and storage speed.
3. Run the Convert2RHEL playbook: After generating conversion data using the Ansible role, you can run the Convert2RHEL playbook on the host to initiate the conversion process. This playbook installs the Convert2RHEL utility and runs it to convert your CentOS machine to RHEL.
4. Update your allocations: After the conversion process is complete, you may need to update your allocations in Foreman to reflect the new host configuration.
It's important to note that Convert2RHEL only supports converting from CentOS Linux 7 to RHEL 7, Oracle Linux 7 to RHEL 7, and Oracle Linux 8 to RHEL 8. If you need to convert from a different version of CentOS or Oracle Linux, you may need to manually enable required repositories and configure activation keys using Ansible variables (<https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/converting_from_an_rpm-based_linux_distribution_to_rhel/index#con_supported-conversion-paths_converting-from-a-linux-distribution-to-rhel>). Additionally, while Convert2RHEL removes unnecessary packages, it does not touch third-party packages or non-Red Hat packages that are not available in RHEL. Therefore, you may need to manually configure these packages after the conversion process is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment