diff --git a/belt_nlp/bert.py b/belt_nlp/bert.py index 482c250..62eb004 100644 --- a/belt_nlp/bert.py +++ b/belt_nlp/bert.py @@ -30,20 +30,21 @@ class BertClassifier(ABC): @abstractmethod def __init__( self, - batch_size: int, - learning_rate: float, - epochs: int, + batch_size: int = 0, # Not needed for embeddings afaik + learning_rate: float = 0.0, # Not needed for embeddings afaik + epochs: int = 0, # Not needed for embeddings afaik accumulation_steps: int = 1, tokenizer: Optional[PreTrainedTokenizerBase] = None, neural_network: Optional[Module] = None, pretrained_model_name_or_path: Optional[str] = "bert-base-uncased", + trust_remote_code: Optional[bool] = False, # Add support for trust remote if needed device: str = "cuda:0", many_gpus: bool = False, ): if not tokenizer: tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path) if not neural_network: - bert = AutoModel.from_pretrained(pretrained_model_name_or_path) + bert = AutoModel.from_pretrained(pretrained_model_name_or_path, trust_remote_code=trust_remote_code) neural_network = BertClassifierNN(bert) self.batch_size = batch_size @@ -172,11 +173,16 @@ def __init__(self, model: Union[BertModel, RobertaModel]): self.linear = Linear(768, 1) self.sigmoid = Sigmoid() - def forward(self, input_ids: Tensor, attention_mask: Tensor) -> Tensor: - x = self.model(input_ids, attention_mask) - x = x[0][:, 0, :] # take token (equiv. to [CLS]) + def forward(self, input_ids: Tensor, attention_mask: Tensor, return_embeddings: bool = False) -> Tensor: + outputs = self.model(input_ids, attention_mask=attention_mask) - # classification head + if return_embeddings: + # Return raw embeddings directly + # Shape: (batch_size, sequence_length, hidden_size) + return outputs.last_hidden_state + + # Proceed with classification otherwise + x = outputs[0][:, 0, :] # Take token (equiv. to [CLS]) x = self.linear(x) x = self.sigmoid(x) return x diff --git a/belt_nlp/bert_embedder_pooling.py b/belt_nlp/bert_embedder_pooling.py new file mode 100644 index 0000000..be25610 --- /dev/null +++ b/belt_nlp/bert_embedder_pooling.py @@ -0,0 +1,112 @@ +import torch + +from belt_nlp.bert_with_pooling import BertClassifier +from typing import Optional, List +from torch import Tensor +from torch.nn import Module +from transformers import PreTrainedTokenizerBase, BatchEncoding +from belt_nlp.splitting import transform_list_of_texts + + +class BertEmbeddingGenerator(BertClassifier): + def __init__( + self, + chunk_size: int, + stride: int, + minimal_chunk_length: int, + pooling_strategy: str = "mean", + maximal_text_length: Optional[int] = None, + tokenizer: Optional[PreTrainedTokenizerBase] = None, + neural_network: Optional[Module] = None, + pretrained_model_name_or_path: Optional[str] = "bert-base-uncased", + trust_remote_code: Optional[bool] = False, + device: str = "cuda:0", + many_gpus: bool = False, + ): + + super().__init__( + tokenizer=tokenizer, + neural_network=neural_network, + pretrained_model_name_or_path=pretrained_model_name_or_path, + trust_remote_code=trust_remote_code, + device=device, + many_gpus=many_gpus + ) + + self.chunk_size = chunk_size + self.stride = stride + self.minimal_chunk_length = minimal_chunk_length + self.maximal_text_length = maximal_text_length + self.pooling_strategy = pooling_strategy + if pooling_strategy not in ["mean", "max"]: + raise ValueError("Unknown pooling strategy!") + + self.collate_fn = BertEmbeddingGenerator.collate_fn_pooled_tokens + + def _tokenize(self, texts: list[str]) -> BatchEncoding: + """ + Transforms list of N texts to the BatchEncoding, that is the dictionary with the following keys: + - input_ids - List of N tensors of the size K(i) x 512 of token ids. + K(i) is the number of chunks of the text i. + Each element of the list is stacked Tensor for encoding of each chunk. + Values of the tensor are integers. + - attention_mask - List of N tensors of the size K(i) x 512 of attention masks. + K(i) is the number of chunks of the text i. + Each element of the list is stacked Tensor for encoding of each chunk. + Values of the tensor are booleans. + + These lists of tensors cannot be stacked into one tensor, + because each text can be divided into different number of chunks. + """ + tokens = transform_list_of_texts( + texts, self.tokenizer, self.chunk_size, self.stride, self.minimal_chunk_length, self.maximal_text_length + ) + return tokens + + def get_embeddings(self, documents: List[str]) -> List[Tensor]: + + all_embeddings = [] + for document in documents: + tokens = self._tokenize([document]) + + input_ids, attention_masks = tokens["input_ids"], tokens["attention_mask"] + + # Process each document's chunks and pool their embeddings + document_embedding = self.process_and_pool_chunks((input_ids, attention_masks)) + all_embeddings.append(document_embedding) + + return torch.stack(all_embeddings).tolist() + + def process_and_pool_chunks(self, batch: tuple[Tensor]): + input_ids = batch[0][0].to(self.device) + attention_mask = batch[1][0].to(self.device) + + model_output = self.neural_network(input_ids, attention_mask=attention_mask, return_embeddings=True) + sequence_output = model_output[:, 0, :] # Taking CLS token as my pretrained model performs better with it + + if self.pooling_strategy == "mean": + pooled_output = torch.mean(sequence_output, dim=0).detach().cpu() + elif self.pooling_strategy == "max": + pooled_output = torch.max(sequence_output, dim=0).values + else: + raise ValueError("Unknown pooling strategy!") + + return pooled_output + + def _evaluate_single_batch(self, batch: tuple[Tensor]) -> Tensor: + pass + + @staticmethod + def collate_fn_pooled_tokens(data): + input_ids = [data[i][0] for i in range(len(data))] + attention_mask = [data[i][1] for i in range(len(data))] + if len(data[0]) == 2: + collated = [input_ids, attention_mask] + else: + labels = Tensor([data[i][2] for i in range(len(data))]) + collated = [input_ids, attention_mask, labels] + return collated + + + + diff --git a/belt_nlp/bert_truncated.py b/belt_nlp/bert_truncated.py index edf1fb2..42150fa 100644 --- a/belt_nlp/bert_truncated.py +++ b/belt_nlp/bert_truncated.py @@ -18,6 +18,7 @@ def __init__( tokenizer: Optional[PreTrainedTokenizerBase] = None, neural_network: Optional[Module] = None, pretrained_model_name_or_path: Optional[str] = "bert-base-uncased", + trust_remote_code: Optional[bool] = False, device: str = "cuda:0", many_gpus: bool = False, ): @@ -29,6 +30,7 @@ def __init__( tokenizer, neural_network, pretrained_model_name_or_path, + trust_remote_code, device, many_gpus, ) diff --git a/belt_nlp/bert_with_pooling.py b/belt_nlp/bert_with_pooling.py index cca5eaa..9e83da4 100644 --- a/belt_nlp/bert_with_pooling.py +++ b/belt_nlp/bert_with_pooling.py @@ -41,6 +41,7 @@ def __init__( tokenizer: Optional[PreTrainedTokenizerBase] = None, neural_network: Optional[Module] = None, pretrained_model_name_or_path: Optional[str] = "bert-base-uncased", + trust_remote_code: Optional[bool] = False, device: str = "cuda:0", many_gpus: bool = False, ): @@ -52,6 +53,7 @@ def __init__( tokenizer, neural_network, pretrained_model_name_or_path, + trust_remote_code, device, many_gpus, ) diff --git a/belt_nlp/test_bert_embedder_pooling.py b/belt_nlp/test_bert_embedder_pooling.py new file mode 100644 index 0000000..ce4e74c --- /dev/null +++ b/belt_nlp/test_bert_embedder_pooling.py @@ -0,0 +1,68 @@ +from belt_nlp.bert_embedder_pooling import BertEmbeddingGenerator + + +# Function generating embeddings on the format I've been testing with +def embed_doc(applications, model): + all_applications_embeddings = {} + for app_id, app_documents in applications.items(): + # Initialize a dictionary for the current application's documents' embeddings + app_embeddings = {} + + # Generate embeddings for the current application's documents + document_embeddings = model.get_embeddings(app_documents) + # Store each document's embedding using a document ID (e.g., "document_1", "document_2", ...) + for i, embedding in enumerate(document_embeddings, start=1): + doc_id = f"document_{i}" + app_embeddings[doc_id] = embedding + + # Store the application's documents' embeddings + all_applications_embeddings[app_id] = app_embeddings + return all_applications_embeddings + +# Functions for checking the embeddings +def print_embeddings_length(applications): + # Iterate through each application in the dictionary + for app_id, documents in applications.items(): + print(f"Application ID: {app_id}") + # Iterate through each document in the application + for doc_id, embeddings in documents.items(): + # Get the length of the embeddings list + length = len(embeddings) + # Print the document ID and the length of its embeddings list + print(f" Document ID: {doc_id}, Embeddings Length: {length}") + + + +if __name__ == '__main__': + + belt_model = BertEmbeddingGenerator( + chunk_size=500, + stride=125, + minimal_chunk_length = 200, + pretrained_model_name_or_path='ltg/norbert3-base', + trust_remote_code=True, + device="cuda", + many_gpus=False + ) + + # Dummy test texts based on the structure I expect to process text in my project + applications = { + "app_1": [ + "The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry.The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry.The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry.", + "The second document discusses at length the challenges of integrating artificial intelligence (AI) into legacy systems, providing a comprehensive analysis of the technical and organizational hurdles that companies face. It covers topics such as compatibility issues, data siloing, and the need for cultural change within organizations to embrace AI technologies. The document offers strategies for overcoming these challenges, including incremental integration approaches, the importance of data cleansing and preparation, and the role of cross-functional teams in facilitating AI adoption. Case studies highlighting successful integrations of AI into existing frameworks are examined to provide practical insights and lessons learned. The document concludes with recommendations for businesses looking to modernize their legacy systems with AI, emphasizing the need for a well-planned strategy that considers both technological and human factors. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry.", + "A third document provides an extensive overview of machine learning algorithms used in predictive analytics, covering a range of techniques from basic linear regression models to more complex neural networks and deep learning approaches. It discusses the applications of these algorithms in various industries, including finance, healthcare, retail, and more, illustrating how predictive analytics can drive decision-making and operational efficiencies. The document delves into the process of selecting appropriate algorithms based on the nature of the data and the specific business problem, including considerations for accuracy, interpretability, and computational efficiency. Additionally, it addresses the challenges of deploying machine learning models in production, such as data drift, model maintenance, and scalability issues. The document also explores future trends in machine learning and predictive analytics, speculating on advancements in algorithmic approaches and their potential impact on business and society. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry." + ], + "app_2": [ + "This application's first document focuses extensively on cloud computing advancements, discussing the evolution of cloud technologies and their transformative impact on the IT industry. It explores various cloud service models, including Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS), and how these models enable businesses to scale resources dynamically according to demand. The document highlights the benefits of cloud computing, such as cost efficiency, scalability, and flexibility, while also addressing the challenges and considerations in cloud adoption, including security, compliance, and data governance. Case studies of companies that have successfully leveraged cloud technologies to enhance their operations and innovate their services are presented. The document concludes with a forward-looking perspective on the future of cloud computing, including emerging technologies like edge computing and quantum cloud computing, and their potential to further revolutionize the IT landscape. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry.", + "Another document within the same application highlights the benefits of cloud storage solutions, providing an in-depth analysis of how cloud storage has become a critical component of data management strategies for businesses of all sizes. It discusses the advantages of cloud storage, such as remote accessibility, disaster recovery, and cost-effectiveness, compared to traditional on-premises storage solutions. The document also examines different types of cloud storage options, including public, private, and hybrid clouds, and their respective use cases. Security concerns and best practices for protecting data in the cloud are thoroughly reviewed, including encryption, access control, and secure data transfer protocols. The discussion extends to the integration of cloud storage with other cloud services and legacy systems, outlining strategies for seamless data management and optimization. The document wraps up with predictions on the future developments in cloud storage technologies, such as enhanced security features, artificial intelligence integration, and improvements in data transfer speeds. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry.", + "The final document explores the security implications of cloud services in great detail, shedding light on the critical importance of cybersecurity in the cloud computing era. It discusses common security threats and vulnerabilities in cloud environments, including data breaches, denial of service (DoS) attacks, and insecure APIs. The document outlines best practices for securing cloud infrastructure and applications, such as implementing robust access controls, regular security audits, and adopting a zero-trust security model. It also covers the role of compliance and regulatory frameworks in ensuring data privacy and protection in the cloud. The impact of emerging technologies, such as blockchain and machine learning, on enhancing cloud security is examined, offering insights into how these technologies can provide advanced threat detection and prevention mechanisms. The document concludes with a discussion on the future of cloud security, anticipating how evolving threats and technologies will shape security strategies in cloud computing. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry." + ], + "app_3": [ + "Document one covers the basics of blockchain technology and its applications extensively, providing readers with a comprehensive understanding of how blockchain works and its potential to transform various sectors. It begins with an introduction to the fundamental concepts of blockchain, such as distributed ledger technology, consensus mechanisms, and smart contracts, and how these components work together to provide a secure, transparent, and tamper-proof system. The document explores a wide range of applications for blockchain beyond cryptocurrencies, including supply chain management, voting systems, and digital identity verification. It also addresses the challenges and limitations of blockchain technology, such as scalability issues and energy consumption, and discusses ongoing research and developments aimed at overcoming these hurdles. The document concludes with a speculative look at the future of blockchain, considering potential innovations and the broader societal impact of widespread blockchain adoption. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry.", + "The next document delves into the impact of blockchain on financial services in depth, examining how blockchain technology is revolutionizing the financial industry by enabling more secure, efficient, and transparent transactions. It discusses the adoption of blockchain in various financial applications, including cross-border payments, securities settlement, and decentralized finance (DeFi) platforms. The document highlights the benefits of blockchain for financial services, such as reduced transaction costs, improved liquidity, and enhanced security, while also considering the regulatory challenges and the need for industry-wide standards. Case studies of financial institutions that have successfully implemented blockchain solutions are presented, offering insights into the practical aspects of blockchain adoption in finance. The document wraps up with predictions on the future role of blockchain in reshaping the financial landscape, including the potential for blockchain to facilitate greater financial inclusion and the emergence of new financial products and services. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry.", + "A concluding document discusses the potential for blockchain in securing digital identities with great detail, highlighting how blockchain technology can offer a more secure, efficient, and user-controlled method of identity verification. It explores the concept of decentralized identities (DIDs) and how blockchain can enable individuals to own and control their digital identities without relying on centralized authorities. The document examines the benefits of using blockchain for identity management, such as enhanced privacy, reduced risk of identity theft, and greater accessibility to digital services. It also addresses the challenges involved in implementing blockchain-based identity systems, including interoperability issues and user adoption. The discussion includes examples of projects and initiatives that are leveraging blockchain for digital identity solutions, providing a glimpse into how this technology is being applied in real-world scenarios. The document concludes with a forward-looking perspective on the evolution of digital identities and the role of blockchain in creating a more secure and inclusive digital world. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry. The first document of the first application delves deeply into the importance of artificial intelligence (AI) in modern software development, exploring various facets such as algorithm optimization, data analysis, and automated decision-making processes. It emphasizes how AI technologies have become indispensable in creating more efficient, intelligent, and user-friendly applications. The document further discusses the integration of AI in developing software solutions, highlighting case studies where AI-driven applications have significantly improved performance and user engagement. Additionally, it touches upon the ethical considerations and potential biases in AI, advocating for responsible development practices that ensure fairness and transparency. The discussion extends to the future of software development in the AI era, speculating on emerging trends, potential challenges, and the evolving role of developers in an increasingly automated industry." + ] + } + + belt_embeds = embed_doc(applications, belt_model) + print_embeddings_length(belt_embeds) \ No newline at end of file