Main

archived_examplesagentsllmsvector-databaseQueryExpansion&RerankerlancedbgptopenaiAImultimodal-aimachine-learningembeddingsfine-tuningexamplesdeep-learninggpt-4-visionllama-indexragmultimodallangchainlancedb-recipes

Install the required dependencies

[3]
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.3/2.3 MB 27.1 MB/s eta 0:00:00
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 49.3/49.3 kB 2.7 MB/s eta 0:00:00
[4]
[5]

We are using langchain fro loading the pdf file & doing prprocessing

[6]
<ipython-input-6-393fdf8f6934>:9: LangChainDeprecationWarning: The class `OpenAIEmbeddings` was deprecated in LangChain 0.0.9 and will be removed in 1.0. An updated version of the class exists in the langchain-openai package and should be used instead. To use it run `pip install -U langchain-openai` and import as `from langchain_openai import OpenAIEmbeddings`.
  embeddings = OpenAIEmbeddings(model="text-embedding-3-large")
35   
Reportable Segments  
Fiscal Year 2022 Compared with Fiscal Year 2021  
Productivity and Business Processes  
Revenue increased $9.4  billion or 18%.  
• Office Commercial products and cloud services revenue increased $4.4  billion or 13%. Office 365 
Commercial revenue grew 18% driven by seat growth of 14%, with continued momentum in small and 
medium business and frontline worker offerings, as well as growth in revenue per user. Office Commercial 
products revenue declined 22% driven by continued customer shift to cloud offerings.  
• Office Consumer products and cloud services revenue increased $641  million or 11% driven by Microsoft 365 
Consumer subscription revenue. Microsoft 365 Consumer subscribers grew 15% to 59.7  million.  
• LinkedIn revenue increased $3.5  billion or 34% driven by a strong job market in our Talent Solutions business 
and advertising demand in our Marketing Solutions business.  
• Dynamics products and cloud services revenue increased 25% driven by Dynamics 365 growth of 39%.  
Operating income increased $5.3  billion or 22%.  
• Gross margin increased $7.3  billion or 17% driven by growth in Office 365 Commercial and LinkedIn. Gross 
margin percentage was relatively unchanged. Excluding the impact of the change in accounting estimate, 
gross margin percentage increased 2 points driven by improvement across all cloud services.  
• Operating expenses increased $2.0  billion or 11% driven by investments in LinkedIn and cloud engineering.  
Gross margin and operating income both included an unfavorable foreign currency impact of 2%.  
Intelligent Cloud  
Revenue increased $15.2  billion or 25%.  
• Server products and cloud services revenue increased $14.7  billion or 28% driven by Azure and other cloud 
services. Azure and other cloud services revenue grew 45% driven by growth in our consumption -based 
services. Server products revenue increased 5% driven by hybrid solutions, including Windows Server and 
SQL Server running in multi -cloud environments.  
• Enterprise Services revenue increased $464  million or 7% driven by growth in Enterprise Support Services.  
Operating income increased $6.6  billion or 25%.  
• Gross margin increased $9.4  billion or 22% driven by growth in Azure and other cloud services. Gross margin 
percentage decreased. Excluding the impact of the change in accounting estimate, gross margin percentage 
was relatively unchanged driven by improvement in Azure and other cloud services, offset in part by sales 
mix shift to Azure and other cloud services.  
• Operating expenses increased $2.8  billion or 16% driven by investments in Azure and other cloud services.  
Revenue and operating income included an unfavorable foreign currency impact of 2% and 3%, respectively.  
More Personal Computing  
Revenue increased $5.6  billion or 10%.  
• Windows revenue increased $2.3  billion or 10% driven by growth in Windows OEM and Windows 
Commercial. Windows OEM revenue increased 11% driven by continued strength in the commercial PC 
market, which has higher revenue per license. Windows Commercial products and cloud services revenue 
increased 11% driven by demand for Microsoft 365.

Query expansion

[7]

its generating query & hypothetica answer

[8]
What were the most important factors that contributed to increases in
revenue? In the current fiscal year, our company experienced
significant revenue growth due to a combination of factors. Firstly, we
successfully launched several new products that were well-received in
the market, leading to increased sales and market share. Additionally,
our strategic marketing initiatives helped to enhance brand awareness
and attract new customers. Furthermore, we expanded our distribution
network, allowing us to reach a wider customer base and drive higher
sales volume. Lastly, cost control measures and operational
efficiencies enabled us to improve profit margins and maximize revenue
generation. Overall, the successful execution of these strategies
significantly contributed to the increase in revenue during the year.
[9]
[Document(metadata={'page': 36, 'source': '/content/microsoft_annual_report_2022.pdf'}, page_content='35   \nReportable Segments  \nFiscal Year 2022 Compared with Fiscal Year 2021  \nProductivity and Business Processes  \nRevenue increased $9.4  billion or 18%.  \n• Office Commercial products and cloud services revenue increased $4.4  billion or 13%. Office 365 \nCommercial revenue grew 18% driven by seat growth of 14%, with continued momentum in small and \nmedium business and frontline worker offerings, as well as growth in revenue per user. Office Commercial \nproducts revenue declined 22% driven by continued customer shift to cloud offerings.  \n• Office Consumer products and cloud services revenue increased $641  million or 11% driven by Microsoft 365 \nConsumer subscription revenue. Microsoft 365 Consumer subscribers grew 15% to 59.7  million.  \n• LinkedIn revenue increased $3.5  billion or 34% driven by a strong job market in our Talent Solutions business \nand advertising demand in our Marketing Solutions business.  \n• Dynamics products and cloud services revenue increased 25% driven by Dynamics 365 growth of 39%.  \nOperating income increased $5.3  billion or 22%.  \n• Gross margin increased $7.3  billion or 17% driven by growth in Office 365 Commercial and LinkedIn. Gross \nmargin percentage was relatively unchanged. Excluding the impact of the change in accounting estimate, \ngross margin percentage increased 2 points driven by improvement across all cloud services.  \n• Operating expenses increased $2.0  billion or 11% driven by investments in LinkedIn and cloud engineering.  \nGross margin and operating income both included an unfavorable foreign currency impact of 2%.  \nIntelligent Cloud  \nRevenue increased $15.2  billion or 25%.  \n• Server products and cloud services revenue increased $14.7  billion or 28% driven by Azure and other cloud \nservices. Azure and other cloud services revenue grew 45% driven by growth in our consumption -based \nservices. Server products revenue increased 5% driven by hybrid solutions, including Windows Server and \nSQL Server running in multi -cloud environments.  \n• Enterprise Services revenue increased $464  million or 7% driven by growth in Enterprise Support Services.  \nOperating income increased $6.6  billion or 25%.  \n• Gross margin increased $9.4  billion or 22% driven by growth in Azure and other cloud services. Gross margin \npercentage decreased. Excluding the impact of the change in accounting estimate, gross margin percentage \nwas relatively unchanged driven by improvement in Azure and other cloud services, offset in part by sales \nmix shift to Azure and other cloud services.  \n• Operating expenses increased $2.8  billion or 16% driven by investments in Azure and other cloud services.  \nRevenue and operating income included an unfavorable foreign currency impact of 2% and 3%, respectively.  \nMore Personal Computing  \nRevenue increased $5.6  billion or 10%.  \n• Windows revenue increased $2.3  billion or 10% driven by growth in Windows OEM and Windows \nCommercial. Windows OEM revenue increased 11% driven by continued strength in the commercial PC \nmarket, which has higher revenue per license. Windows Commercial products and cloud services revenue \nincreased 11% driven by demand for Microsoft 365.'), Document(metadata={'page': 32, 'source': '/content/microsoft_annual_report_2022.pdf'}, page_content='31   \nIndustry Trends  \nOur industry is dynamic and highly competitive, with frequent changes in both technologies and business models. Each \nindustry shift is an opportunity to conceive new products, new technologies, or new ideas that can further transform the \nindustry and our business. At Microsoft, we push the boundaries of what is possible through a broad range of research \nand development activities that seek to identify and address the changing demands of customers and users, industry \ntrends, and competitive forces.  \nEconomic Conditions, Challenges, and Risks  \nThe markets for software, devices, and cloud -based services are dynamic and highly competitive. Our competitors are \ndeveloping new software and devices, while also deploying competing cloud -based services for consumers and \nbusinesses. The devices and form factors customers prefer evolve rapidly, and influence how users access services in \nthe cloud, and in some cases, the user’s choice of which suite of cloud -based services to use. We must continue to evolve \nand adapt over an extended time in pace with this changing environment. The investments we are making in infrastructure \nand devices will continue to increase our operating costs and may decrease our operating margins.  \nOur success is highly dependent on our ability to attract and retain qualified employees. We hire a mix of university and \nindustry talent worldwide. We compete for talented individuals globally by offering an exceptional working environment, \nbroad customer reach, scale in resources, the ability to grow one’s career across many different products and businesses, \nand competitive compensation and benefits. Aggregate demand for our software, services, and devices is correlated to \nglobal macroeconomic and geopolitical factors, which remain dynamic.  \nOur devices are primarily manufactured by third -party contract manufacturers, some of which contain certain components \nfor which there are very few qualified suppliers. For these components, we have limited near -term flexibility to use other \nmanufacturers if a current vendor becomes unavailable or is unable to meet our requirements. Extended disruptions at \nthese suppliers and/or manufacturers could lead to a similar disruption in our ability to manufacture devices on time to \nmeet consumer demand.  \nOur international operations provide a significant portion of our total revenue and expenses. Many of these revenue and \nexpenses are denominated in currencies other than the U.S. dollar. As a result, changes in foreign exchange rates may \nsignificantly affect revenue and expenses. Fluctuations in the U.S. dollar relative to certain foreign currencies did not hav e \na material impact on reported revenue or expenses from our international operations in fiscal year 2022.  \nRefer to Risk Factors in our fiscal year 2022 Form 10 -K for a discussion of these factors and other risks.  \nSeasonality  \nOur revenue fluctuates quarterly and is generally higher in the second and fourth quarters of our fiscal year. Second \nquarter revenue is driven by corporate year -end spending trends in our major markets and holiday season spending by \nconsumers, and fourth quarter revenue is driven by the volume of multi -year on -premises contracts executed during the \nperiod.  \nReportable Segments  \nWe report our financial performance based on the following segments: Productivity and Business Processes, Intelligent \nCloud, and More Personal Computing. The segment amounts included in MD&A are presented on a basis consistent with \nour internal management reporting. Additional information on our reportable segments is contained in Note 19 – Segment \nInformation and Geographic Data of the Notes to Financial Statements in our fiscal year 2022 Form 10 -K.  \nMetrics  \nWe use metrics in assessing the performance of our business and to make informed decisions regarding the allocation of'), Document(metadata={'page': 34, 'source': '/content/microsoft_annual_report_2022.pdf'}, page_content='33 Dynamics products and cloud services revenue growth  Revenue from Dynamics products and cloud services, \nincluding Dynamics 365, comprising a set of intelligent, \ncloud -based applications across ERP, CRM, Customer \nInsights, Power Apps, and Power Automate; and on -\npremises ERP and CRM applications  \n    \nLinkedIn revenue growth  Revenue from LinkedIn, including Talent Solutions, \nMarketing Solutions, Premium Subscriptions, and Sales \nSolutions  \n    \nServer products and cloud services revenue growth  Revenue from Server products and cloud services, \nincluding Azure and other cloud services; SQL Server, \nWindows Server, Visual Studio, System Center, and \nrelated Client Access Licenses (“CALs”); and Nuance and \nGitHub  \nMore Personal Computing  \nMetrics related to our More Personal Computing segment assess the performance of key lines of business within this \nsegment. These metrics provide strategic product insights which allow us to assess the performance across our \ncommercial and consumer businesses. As we have diversity of target audiences and sales motions within the Windows \nbusiness, we monitor metrics that are reflective of those varying motions.  \n  \nWindows OEM revenue growth  Revenue from sales of Windows Pro and non -Pro licenses sold \nthrough the OEM channel  \n    \nWindows Commercial products and cloud \nservices revenue growth  Revenue from Windows Commercial products and cloud services, \ncomprising volume licensing of the Windows operating system, \nWindows cloud services, and other Windows commercial offerings  \n    \nSurface revenue growth  Revenue from Surface devices and accessories  \n    \nXbox content and services revenue growth  Revenue from Xbox content and services, comprising first - and third -\nparty content (including games and in -game content), Xbox Game \nPass and other subscriptions, Xbox Cloud Gaming, third -party disc \nroyalties, advertising, and other cloud services  \n    \nSearch and news advertising revenue, \nexcluding TAC, growth  Revenue from search and news advertising excluding traffic \nacquisition costs (“TAC”) paid to Bing Ads network publishers and \nnews partners  \nSUMMARY RESULTS OF OPERATIONS  \n  \n(In millions,  except  percentages  and per share  amounts)  2022  2021  Percentage  \nChange    \n        \nRevenue  $  198,270   $  168,088    18%  \nGross margin   135,620    115,856    17%  \nOperating income   83,383    69,916    19%  \nNet income   72,738    61,271    19%  \nDiluted earnings per share   9.65   8.05   20%  \n        \nAdjusted net income (non -GAAP)   69,447    60,651    15%  \nAdjusted diluted earnings per share (non -GAAP)   9.21   7.97   16%    \nAdjusted net income and adjusted diluted earnings per share (“EPS”) are non -GAAP financial measures which exclude \nthe net  income tax benefit related to transfer of intangible properties in the first quarter of fiscal year 2022 and the'), Document(metadata={'page': 35, 'source': '/content/microsoft_annual_report_2022.pdf'}, page_content='34 net income tax benefit related to an India Supreme Court decision on withholding taxes in the third quarter of fiscal year \n2021. Refer to the Non -GAAP Financial Measures section below for a reconciliation of our financial results reported in \naccordance with GAAP to non -GAAP financial results. See Note 12 – Income Taxes of the Notes to Financial Statements \nin our fiscal year 2022 Form 10 -K for further discussion.  \nFiscal Year 2022 Compared with Fiscal Year 2021  \nRevenue increased $30.2  billion or 18% driven by growth across each of our segments. Intelligent Cloud revenue \nincreased driven by Azure and other cloud services. Productivity and Business Processes revenue increased driven by \nOffice 365 Commercial and LinkedIn. More Personal Computing revenue increased driven by Search and news \nadvertising and Windows.  \nCost of revenue increased $10.4  billion or 20% driven by growth in Microsoft Cloud.  \nGross margin increased $19.8  billion or 17% driven by growth across each of our segments.  \n• Gross margin percentage decreased slightly. Excluding the impact of the fiscal year 2021 change in \naccounting estimate for the useful lives of our server and network equipment, gross margin percentage \nincreased 1 point driven by improvement in Productivity and Business Processes.  \n• Microsoft Cloud gross margin percentage decreased slightly to 70%. Excluding the impact of the change in \naccounting estimate, Microsoft Cloud gross margin percentage increased 3 points driven by improvement \nacross our cloud services, offset in part by sales mix shift to Azure and other cloud services.  \nOperating expenses increased $6.3  billion or 14% driven by investments in cloud engineering, LinkedIn, Gaming, and \ncommercial sales.  \nKey changes in operating expenses were:  \n• Research and development expenses increased $3.8  billion or 18% driven by investments in cloud \nengineering, Gaming, and LinkedIn.  \n• Sales and marketing expenses increased $1.7  billion or 8% driven by investments in commercial sales and \nLinkedIn. Sales and marketing included a favorable foreign currency impact of 2%.  \n• General and administrative expenses increased $793  million or 16% driven by investments in corporate \nfunctions.  \nOperating income increased $13.5  billion or 19% driven by growth across each of our segments.  \nCurrent year net income and diluted EPS were positively impacted by the net tax benefit related to the transfer of \nintangible properties, which resulted in an increase to net income and diluted EPS of $3.3  billion and $0.44, respectively. \nPrior year net income and diluted EPS were positively impacted by the net tax benefit related to the India Supreme Court \ndecision on withholding taxes, which resulted in an increase to net income and diluted EPS of $620  million and $0.08, \nrespectively.  \nGross margin and operating income both included an unfavorable foreign currency impact of 2%.  \nSEGMENT RESULTS OF OPERATIONS  \n  \n(In millions, except percentages)  2022  2021  Percentage  \nChange    \n        \nRevenue        \n        \nProductivity and Business Processes  $ 63,364   $ 53,915    18%  \nIntelligent Cloud   75,251    60,080    25%  \nMore Personal Computing   59,655    54,093    10%        \nTotal  $   198,270   $  168,088    18%          \n        \nOperating Income        \n        \nProductivity and Business Processes  $ 29,687   $ 24,351    22%  \nIntelligent Cloud   32,721    26,126    25%  \nMore Personal Computing   20,975    19,439    8%        \nTotal  $ 83,383   $ 69,916    19%')]
[10]
35   
Reportable Segments  
Fiscal Year 2022 Compared with Fiscal Year 2021  
Productivity and Business Processes  
Revenue increased $9.4  billion or 18%.  
• Office Commercial products and cloud services revenue increased $4.4  billion or 13%. Office 365 
Commercial revenue grew 18% driven by seat growth of 14%, with continued momentum in small and 
medium business and frontline worker offerings, as well as growth in revenue per user. Office Commercial 
products revenue declined 22% driven by continued customer shift to cloud offerings.  
• Office Consumer products and cloud services revenue increased $641  million or 11% driven by Microsoft 365 
Consumer subscription revenue. Microsoft 365 Consumer subscribers grew 15% to 59.7  million.  
• LinkedIn revenue increased $3.5  billion or 34% driven by a strong job market in our Talent Solutions business 
and advertising demand in our Marketing Solutions business.  
• Dynamics products and cloud services revenue increased 25% driven by Dynamics 365 growth of 39%.  
Operating income increased $5.3  billion or 22%.  
• Gross margin increased $7.3  billion or 17% driven by growth in Office 365 Commercial and LinkedIn. Gross 
margin percentage was relatively unchanged. Excluding the impact of the change in accounting estimate, 
gross margin percentage increased 2 points driven by improvement across all cloud services.  
• Operating expenses increased $2.0  billion or 11% driven by investments in LinkedIn and cloud engineering.  
Gross margin and operating income both included an unfavorable foreign currency impact of 2%.  
Intelligent Cloud  
Revenue increased $15.2  billion or 25%.  
• Server products and cloud services revenue increased $14.7  billion or 28% driven by Azure and other cloud 
services. Azure and other cloud services revenue grew 45% driven by growth in our consumption -based 
services. Server products revenue increased 5% driven by hybrid solutions, including Windows Server and 
SQL Server running in multi -cloud environments.  
• Enterprise Services revenue increased $464  million or 7% driven by growth in Enterprise Support Services.  
Operating income increased $6.6  billion or 25%.  
• Gross margin increased $9.4  billion or 22% driven by growth in Azure and other cloud services. Gross margin 
percentage decreased. Excluding the impact of the change in accounting estimate, gross margin percentage 
was relatively unchanged driven by improvement in Azure and other cloud services, offset in part by sales 
mix shift to Azure and other cloud services.  
• Operating expenses increased $2.8  billion or 16% driven by investments in Azure and other cloud services.  
Revenue and operating income included an unfavorable foreign currency impact of 2% and 3%, respectively.  
More Personal Computing  
Revenue increased $5.6  billion or 10%.  
• Windows revenue increased $2.3  billion or 10% driven by growth in Windows OEM and Windows 
Commercial. Windows OEM revenue increased 11% driven by continued strength in the commercial PC 
market, which has higher revenue per license. Windows Commercial products and cloud services revenue 
increased 11% driven by demand for Microsoft 365.

#Reranker model

we are using landb for colbertv2 implementation COlbertv2 is reranker method helpful for improving the ranking of results its returning top ranking results as the most relevant to your particular query.

for more technical details please check the blog :

[11]
31   
Industry Trends  
Our industry is dynamic and highly competitive, with frequent changes in both technologies and business models. Each 
industry shift is an opportunity to conceive new products, new technologies, or new ideas that can further transform the 
industry and our business. At Microsoft, we push the boundaries of what is possible through a broad range of research 
and development activities that seek to identify and address the changing demands of customers and users, industry 
trends, and competitive forces.  
Economic Conditions, Challenges, and Risks  
The markets for software, devices, and cloud -based services are dynamic and highly competitive. Our competitors are 
developing new software and devices, while also deploying competing cloud -based services for consumers and 
businesses. The devices and form factors customers prefer evolve rapidly, and influence how users access services in 
the cloud, and in some cases, the user’s choice of which suite of cloud -based services to use. We must continue to evolve 
and adapt over an extended time in pace with this changing environment. The investments we are making in infrastructure 
and devices will continue to increase our operating costs and may decrease our operating margins.  
Our success is highly dependent on our ability to attract and retain qualified employees. We hire a mix of university and 
industry talent worldwide. We compete for talented individuals globally by offering an exceptional working environment, 
broad customer reach, scale in resources, the ability to grow one’s career across many different products and businesses, 
and competitive compensation and benefits. Aggregate demand for our software, services, and devices is correlated to 
global macroeconomic and geopolitical factors, which remain dynamic.  
Our devices are primarily manufactured by third -party contract manufacturers, some of which contain certain components 
for which there are very few qualified suppliers. For these components, we have limited near -term flexibility to use other 
manufacturers if a current vendor becomes unavailable or is unable to meet our requirements. Extended disruptions at 
these suppliers and/or manufacturers could lead to a similar disruption in our ability to manufacture devices on time to 
meet consumer demand.  
Our international operations provide a significant portion of our total revenue and expenses. Many of these revenue and 
expenses are denominated in currencies other than the U.S. dollar. As a result, changes in foreign exchange rates may 
significantly affect revenue and expenses. Fluctuations in the U.S. dollar relative to certain foreign currencies did not hav e 
a material impact on reported revenue or expenses from our international operations in fiscal year 2022.  
Refer to Risk Factors in our fiscal year 2022 Form 10 -K for a discussion of these factors and other risks.  
Seasonality  
Our revenue fluctuates quarterly and is generally higher in the second and fourth quarters of our fiscal year. Second 
quarter revenue is driven by corporate year -end spending trends in our major markets and holiday season spending by 
consumers, and fourth quarter revenue is driven by the volume of multi -year on -premises contracts executed during the 
period.  
Reportable Segments  
We report our financial performance based on the following segments: Productivity and Business Processes, Intelligent 
Cloud, and More Personal Computing. The segment amounts included in MD&A are presented on a basis consistent with 
our internal management reporting. Additional information on our reportable segments is contained in Note 19 – Segment 
Information and Geographic Data of the Notes to Financial Statements in our fiscal year 2022 Form 10 -K.  
Metrics  
We use metrics in assessing the performance of our business and to make informed decisions regarding the allocation of

#Colbertv2 reranker model

[16]
Collecting rerankers
  Downloading rerankers-0.5.3-py3-none-any.whl.metadata (27 kB)
Requirement already satisfied: pydantic in /usr/local/lib/python3.10/dist-packages (from rerankers) (2.9.1)
Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from rerankers) (4.66.5)
Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic->rerankers) (0.7.0)
Requirement already satisfied: pydantic-core==2.23.3 in /usr/local/lib/python3.10/dist-packages (from pydantic->rerankers) (2.23.3)
Requirement already satisfied: typing-extensions>=4.6.1 in /usr/local/lib/python3.10/dist-packages (from pydantic->rerankers) (4.12.2)
Downloading rerankers-0.5.3-py3-none-any.whl (37 kB)
Installing collected packages: rerankers
Successfully installed rerankers-0.5.3
[17]
Loading ColBERTRanker model colbert-ir/colbertv2.0
No device set
Using device cpu
No dtype set
Device set to `cpu`, setting dtype to `float32`
Using dtype torch.float32
Loading model colbert-ir/colbertv2.0, this might take a while...
/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:89: UserWarning: 
The secret `HF_TOKEN` does not exist in your Colab secrets.
To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.
You will be able to reuse this secret in all of your notebooks.
Please note that authentication is recommended but still optional to access public models or datasets.
  warnings.warn(
tokenizer_config.json:   0%|          | 0.00/405 [00:00<?, ?B/s]
vocab.txt:   0%|          | 0.00/232k [00:00<?, ?B/s]
tokenizer.json:   0%|          | 0.00/466k [00:00<?, ?B/s]
special_tokens_map.json:   0%|          | 0.00/112 [00:00<?, ?B/s]
/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base.py:1601: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted in transformers v4.45, and will be then set to `False` by default. For more details check this issue: https://github.com/huggingface/transformers/issues/31884
  warnings.warn(
config.json:   0%|          | 0.00/743 [00:00<?, ?B/s]
model.safetensors:   0%|          | 0.00/438M [00:00<?, ?B/s]
Linear Dim set to: {linear_dim} for downcasting
[18]

Lets try the CrossEncoder for getting relavant docus from it

cross-encoder reranker model

Re-ranking is a way to order results and score them according to their relevancy to a particular query. So let's take a look at how this works underneath. In re-ranking, after you retrieve results for a particular query, you pass these results along with your query to a re-ranking model. This allows you to re-rank the output so the most relevant results have the highest rank. Another way to think about this is your re-ranking model scores each of the results conditioned on the query, and those with the highest score are the most relevant. Then you can just select the top ranking results as the most relevant to your particular query. So let's take a look at how to do this in practice

[19]
config.json:   0%|          | 0.00/794 [00:00<?, ?B/s]
pytorch_model.bin:   0%|          | 0.00/90.9M [00:00<?, ?B/s]
tokenizer_config.json:   0%|          | 0.00/316 [00:00<?, ?B/s]
vocab.txt:   0%|          | 0.00/232k [00:00<?, ?B/s]
special_tokens_map.json:   0%|          | 0.00/112 [00:00<?, ?B/s]
/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base.py:1601: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted in transformers v4.45, and will be then set to `False` by default. For more details check this issue: https://github.com/huggingface/transformers/issues/31884
  warnings.warn(
Scores:
-4.676173
-4.906811
-9.046174
-3.4381006
New Ordering:
4
1
2
3
[20]
[['What were the most important factors that contributed to increases in revenue?',
,  '35   \nReportable Segments  \nFiscal Year 2022 Compared with Fiscal Year 2021  \nProductivity and Business Processes  \nRevenue increased $9.4  billion or 18%.  \n• Office Commercial products and cloud services revenue increased $4.4  billion or 13%. Office 365 \nCommercial revenue grew 18% driven by seat growth of 14%, with continued momentum in small and \nmedium business and frontline worker offerings, as well as growth in revenue per user. Office Commercial \nproducts revenue declined 22% driven by continued customer shift to cloud offerings.  \n• Office Consumer products and cloud services revenue increased $641  million or 11% driven by Microsoft 365 \nConsumer subscription revenue. Microsoft 365 Consumer subscribers grew 15% to 59.7  million.  \n• LinkedIn revenue increased $3.5  billion or 34% driven by a strong job market in our Talent Solutions business \nand advertising demand in our Marketing Solutions business.  \n• Dynamics products and cloud services revenue increased 25% driven by Dynamics 365 growth of 39%.  \nOperating income increased $5.3  billion or 22%.  \n• Gross margin increased $7.3  billion or 17% driven by growth in Office 365 Commercial and LinkedIn. Gross \nmargin percentage was relatively unchanged. Excluding the impact of the change in accounting estimate, \ngross margin percentage increased 2 points driven by improvement across all cloud services.  \n• Operating expenses increased $2.0  billion or 11% driven by investments in LinkedIn and cloud engineering.  \nGross margin and operating income both included an unfavorable foreign currency impact of 2%.  \nIntelligent Cloud  \nRevenue increased $15.2  billion or 25%.  \n• Server products and cloud services revenue increased $14.7  billion or 28% driven by Azure and other cloud \nservices. Azure and other cloud services revenue grew 45% driven by growth in our consumption -based \nservices. Server products revenue increased 5% driven by hybrid solutions, including Windows Server and \nSQL Server running in multi -cloud environments.  \n• Enterprise Services revenue increased $464  million or 7% driven by growth in Enterprise Support Services.  \nOperating income increased $6.6  billion or 25%.  \n• Gross margin increased $9.4  billion or 22% driven by growth in Azure and other cloud services. Gross margin \npercentage decreased. Excluding the impact of the change in accounting estimate, gross margin percentage \nwas relatively unchanged driven by improvement in Azure and other cloud services, offset in part by sales \nmix shift to Azure and other cloud services.  \n• Operating expenses increased $2.8  billion or 16% driven by investments in Azure and other cloud services.  \nRevenue and operating income included an unfavorable foreign currency impact of 2% and 3%, respectively.  \nMore Personal Computing  \nRevenue increased $5.6  billion or 10%.  \n• Windows revenue increased $2.3  billion or 10% driven by growth in Windows OEM and Windows \nCommercial. Windows OEM revenue increased 11% driven by continued strength in the commercial PC \nmarket, which has higher revenue per license. Windows Commercial products and cloud services revenue \nincreased 11% driven by demand for Microsoft 365.'],
, ['What were the most important factors that contributed to increases in revenue?',
,  '31   \nIndustry Trends  \nOur industry is dynamic and highly competitive, with frequent changes in both technologies and business models. Each \nindustry shift is an opportunity to conceive new products, new technologies, or new ideas that can further transform the \nindustry and our business. At Microsoft, we push the boundaries of what is possible through a broad range of research \nand development activities that seek to identify and address the changing demands of customers and users, industry \ntrends, and competitive forces.  \nEconomic Conditions, Challenges, and Risks  \nThe markets for software, devices, and cloud -based services are dynamic and highly competitive. Our competitors are \ndeveloping new software and devices, while also deploying competing cloud -based services for consumers and \nbusinesses. The devices and form factors customers prefer evolve rapidly, and influence how users access services in \nthe cloud, and in some cases, the user’s choice of which suite of cloud -based services to use. We must continue to evolve \nand adapt over an extended time in pace with this changing environment. The investments we are making in infrastructure \nand devices will continue to increase our operating costs and may decrease our operating margins.  \nOur success is highly dependent on our ability to attract and retain qualified employees. We hire a mix of university and \nindustry talent worldwide. We compete for talented individuals globally by offering an exceptional working environment, \nbroad customer reach, scale in resources, the ability to grow one’s career across many different products and businesses, \nand competitive compensation and benefits. Aggregate demand for our software, services, and devices is correlated to \nglobal macroeconomic and geopolitical factors, which remain dynamic.  \nOur devices are primarily manufactured by third -party contract manufacturers, some of which contain certain components \nfor which there are very few qualified suppliers. For these components, we have limited near -term flexibility to use other \nmanufacturers if a current vendor becomes unavailable or is unable to meet our requirements. Extended disruptions at \nthese suppliers and/or manufacturers could lead to a similar disruption in our ability to manufacture devices on time to \nmeet consumer demand.  \nOur international operations provide a significant portion of our total revenue and expenses. Many of these revenue and \nexpenses are denominated in currencies other than the U.S. dollar. As a result, changes in foreign exchange rates may \nsignificantly affect revenue and expenses. Fluctuations in the U.S. dollar relative to certain foreign currencies did not hav e \na material impact on reported revenue or expenses from our international operations in fiscal year 2022.  \nRefer to Risk Factors in our fiscal year 2022 Form 10 -K for a discussion of these factors and other risks.  \nSeasonality  \nOur revenue fluctuates quarterly and is generally higher in the second and fourth quarters of our fiscal year. Second \nquarter revenue is driven by corporate year -end spending trends in our major markets and holiday season spending by \nconsumers, and fourth quarter revenue is driven by the volume of multi -year on -premises contracts executed during the \nperiod.  \nReportable Segments  \nWe report our financial performance based on the following segments: Productivity and Business Processes, Intelligent \nCloud, and More Personal Computing. The segment amounts included in MD&A are presented on a basis consistent with \nour internal management reporting. Additional information on our reportable segments is contained in Note 19 – Segment \nInformation and Geographic Data of the Notes to Financial Statements in our fiscal year 2022 Form 10 -K.  \nMetrics  \nWe use metrics in assessing the performance of our business and to make informed decisions regarding the allocation of'],
, ['What were the most important factors that contributed to increases in revenue?',
,  '33 Dynamics products and cloud services revenue growth  Revenue from Dynamics products and cloud services, \nincluding Dynamics 365, comprising a set of intelligent, \ncloud -based applications across ERP, CRM, Customer \nInsights, Power Apps, and Power Automate; and on -\npremises ERP and CRM applications  \n    \nLinkedIn revenue growth  Revenue from LinkedIn, including Talent Solutions, \nMarketing Solutions, Premium Subscriptions, and Sales \nSolutions  \n    \nServer products and cloud services revenue growth  Revenue from Server products and cloud services, \nincluding Azure and other cloud services; SQL Server, \nWindows Server, Visual Studio, System Center, and \nrelated Client Access Licenses (“CALs”); and Nuance and \nGitHub  \nMore Personal Computing  \nMetrics related to our More Personal Computing segment assess the performance of key lines of business within this \nsegment. These metrics provide strategic product insights which allow us to assess the performance across our \ncommercial and consumer businesses. As we have diversity of target audiences and sales motions within the Windows \nbusiness, we monitor metrics that are reflective of those varying motions.  \n  \nWindows OEM revenue growth  Revenue from sales of Windows Pro and non -Pro licenses sold \nthrough the OEM channel  \n    \nWindows Commercial products and cloud \nservices revenue growth  Revenue from Windows Commercial products and cloud services, \ncomprising volume licensing of the Windows operating system, \nWindows cloud services, and other Windows commercial offerings  \n    \nSurface revenue growth  Revenue from Surface devices and accessories  \n    \nXbox content and services revenue growth  Revenue from Xbox content and services, comprising first - and third -\nparty content (including games and in -game content), Xbox Game \nPass and other subscriptions, Xbox Cloud Gaming, third -party disc \nroyalties, advertising, and other cloud services  \n    \nSearch and news advertising revenue, \nexcluding TAC, growth  Revenue from search and news advertising excluding traffic \nacquisition costs (“TAC”) paid to Bing Ads network publishers and \nnews partners  \nSUMMARY RESULTS OF OPERATIONS  \n  \n(In millions,  except  percentages  and per share  amounts)  2022  2021  Percentage  \nChange    \n        \nRevenue  $  198,270   $  168,088    18%  \nGross margin   135,620    115,856    17%  \nOperating income   83,383    69,916    19%  \nNet income   72,738    61,271    19%  \nDiluted earnings per share   9.65   8.05   20%  \n        \nAdjusted net income (non -GAAP)   69,447    60,651    15%  \nAdjusted diluted earnings per share (non -GAAP)   9.21   7.97   16%    \nAdjusted net income and adjusted diluted earnings per share (“EPS”) are non -GAAP financial measures which exclude \nthe net  income tax benefit related to transfer of intangible properties in the first quarter of fiscal year 2022 and the'],
, ['What were the most important factors that contributed to increases in revenue?',
,  '34 net income tax benefit related to an India Supreme Court decision on withholding taxes in the third quarter of fiscal year \n2021. Refer to the Non -GAAP Financial Measures section below for a reconciliation of our financial results reported in \naccordance with GAAP to non -GAAP financial results. See Note 12 – Income Taxes of the Notes to Financial Statements \nin our fiscal year 2022 Form 10 -K for further discussion.  \nFiscal Year 2022 Compared with Fiscal Year 2021  \nRevenue increased $30.2  billion or 18% driven by growth across each of our segments. Intelligent Cloud revenue \nincreased driven by Azure and other cloud services. Productivity and Business Processes revenue increased driven by \nOffice 365 Commercial and LinkedIn. More Personal Computing revenue increased driven by Search and news \nadvertising and Windows.  \nCost of revenue increased $10.4  billion or 20% driven by growth in Microsoft Cloud.  \nGross margin increased $19.8  billion or 17% driven by growth across each of our segments.  \n• Gross margin percentage decreased slightly. Excluding the impact of the fiscal year 2021 change in \naccounting estimate for the useful lives of our server and network equipment, gross margin percentage \nincreased 1 point driven by improvement in Productivity and Business Processes.  \n• Microsoft Cloud gross margin percentage decreased slightly to 70%. Excluding the impact of the change in \naccounting estimate, Microsoft Cloud gross margin percentage increased 3 points driven by improvement \nacross our cloud services, offset in part by sales mix shift to Azure and other cloud services.  \nOperating expenses increased $6.3  billion or 14% driven by investments in cloud engineering, LinkedIn, Gaming, and \ncommercial sales.  \nKey changes in operating expenses were:  \n• Research and development expenses increased $3.8  billion or 18% driven by investments in cloud \nengineering, Gaming, and LinkedIn.  \n• Sales and marketing expenses increased $1.7  billion or 8% driven by investments in commercial sales and \nLinkedIn. Sales and marketing included a favorable foreign currency impact of 2%.  \n• General and administrative expenses increased $793  million or 16% driven by investments in corporate \nfunctions.  \nOperating income increased $13.5  billion or 19% driven by growth across each of our segments.  \nCurrent year net income and diluted EPS were positively impacted by the net tax benefit related to the transfer of \nintangible properties, which resulted in an increase to net income and diluted EPS of $3.3  billion and $0.44, respectively. \nPrior year net income and diluted EPS were positively impacted by the net tax benefit related to the India Supreme Court \ndecision on withholding taxes, which resulted in an increase to net income and diluted EPS of $620  million and $0.08, \nrespectively.  \nGross margin and operating income both included an unfavorable foreign currency impact of 2%.  \nSEGMENT RESULTS OF OPERATIONS  \n  \n(In millions, except percentages)  2022  2021  Percentage  \nChange    \n        \nRevenue        \n        \nProductivity and Business Processes  $ 63,364   $ 53,915    18%  \nIntelligent Cloud   75,251    60,080    25%  \nMore Personal Computing   59,655    54,093    10%        \nTotal  $   198,270   $  168,088    18%          \n        \nOperating Income        \n        \nProductivity and Business Processes  $ 29,687   $ 24,351    22%  \nIntelligent Cloud   32,721    26,126    25%  \nMore Personal Computing   20,975    19,439    8%        \nTotal  $ 83,383   $ 69,916    19%']]

Now you can use this reranked documents & pass it to llm & get relavant results. please check our other techical blogs also where we have explained other important methods of how you can improve your rag

#FlashRanker

Ultra-lite & Super-fast Python library to add re-ranking to your existing search & retrieval pipelines. It is based on SoTA cross-encoders.

[21]
Collecting flashrank
  Downloading FlashRank-0.2.9-py3-none-any.whl.metadata (12 kB)
Requirement already satisfied: tokenizers in /usr/local/lib/python3.10/dist-packages (from flashrank) (0.19.1)
Collecting onnxruntime (from flashrank)
  Downloading onnxruntime-1.19.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (4.5 kB)
Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from flashrank) (1.26.4)
Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from flashrank) (2.32.3)
Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from flashrank) (4.66.5)
Collecting coloredlogs (from onnxruntime->flashrank)
  Downloading coloredlogs-15.0.1-py2.py3-none-any.whl.metadata (12 kB)
Requirement already satisfied: flatbuffers in /usr/local/lib/python3.10/dist-packages (from onnxruntime->flashrank) (24.3.25)
Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from onnxruntime->flashrank) (24.1)
Requirement already satisfied: protobuf in /usr/local/lib/python3.10/dist-packages (from onnxruntime->flashrank) (3.20.3)
Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from onnxruntime->flashrank) (1.13.2)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->flashrank) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->flashrank) (3.8)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->flashrank) (2.0.7)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->flashrank) (2024.8.30)
Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /usr/local/lib/python3.10/dist-packages (from tokenizers->flashrank) (0.24.6)
Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers->flashrank) (3.16.0)
Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers->flashrank) (2024.6.1)
Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers->flashrank) (6.0.2)
Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers->flashrank) (4.12.2)
Collecting humanfriendly>=9.1 (from coloredlogs->onnxruntime->flashrank)
  Downloading humanfriendly-10.0-py2.py3-none-any.whl.metadata (9.2 kB)
Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from sympy->onnxruntime->flashrank) (1.3.0)
Downloading FlashRank-0.2.9-py3-none-any.whl (19 kB)
Downloading onnxruntime-1.19.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (13.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.2/13.2 MB 56.2 MB/s eta 0:00:00
Downloading coloredlogs-15.0.1-py2.py3-none-any.whl (46 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.0/46.0 kB 2.8 MB/s eta 0:00:00
Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 86.8/86.8 kB 6.2 MB/s eta 0:00:00
Installing collected packages: humanfriendly, coloredlogs, onnxruntime, flashrank
Successfully installed coloredlogs-15.0.1 flashrank-0.2.9 humanfriendly-10.0 onnxruntime-1.19.2
[22]
ms-marco-MiniLM-L-12-v2.zip: 100%|██████████| 21.6M/21.6M [00:00<00:00, 106MiB/s]
[{'text': '35   \nReportable Segments  \nFiscal Year 2022 Compared with Fiscal Year 2021  \nProductivity and Business Processes  \nRevenue increased $9.4  billion or 18%.  \n• Office Commercial products and cloud services revenue increased $4.4  billion or 13%. Office 365 \nCommercial revenue grew 18% driven by seat growth of 14%, with continued momentum in small and \nmedium business and frontline worker offerings, as well as growth in revenue per user. Office Commercial \nproducts revenue declined 22% driven by continued customer shift to cloud offerings.  \n• Office Consumer products and cloud services revenue increased $641  million or 11% driven by Microsoft 365 \nConsumer subscription revenue. Microsoft 365 Consumer subscribers grew 15% to 59.7  million.  \n• LinkedIn revenue increased $3.5  billion or 34% driven by a strong job market in our Talent Solutions business \nand advertising demand in our Marketing Solutions business.  \n• Dynamics products and cloud services revenue increased 25% driven by Dynamics 365 growth of 39%.  \nOperating income increased $5.3  billion or 22%.  \n• Gross margin increased $7.3  billion or 17% driven by growth in Office 365 Commercial and LinkedIn. Gross \nmargin percentage was relatively unchanged. Excluding the impact of the change in accounting estimate, \ngross margin percentage increased 2 points driven by improvement across all cloud services.  \n• Operating expenses increased $2.0  billion or 11% driven by investments in LinkedIn and cloud engineering.  \nGross margin and operating income both included an unfavorable foreign currency impact of 2%.  \nIntelligent Cloud  \nRevenue increased $15.2  billion or 25%.  \n• Server products and cloud services revenue increased $14.7  billion or 28% driven by Azure and other cloud \nservices. Azure and other cloud services revenue grew 45% driven by growth in our consumption -based \nservices. Server products revenue increased 5% driven by hybrid solutions, including Windows Server and \nSQL Server running in multi -cloud environments.  \n• Enterprise Services revenue increased $464  million or 7% driven by growth in Enterprise Support Services.  \nOperating income increased $6.6  billion or 25%.  \n• Gross margin increased $9.4  billion or 22% driven by growth in Azure and other cloud services. Gross margin \npercentage decreased. Excluding the impact of the change in accounting estimate, gross margin percentage \nwas relatively unchanged driven by improvement in Azure and other cloud services, offset in part by sales \nmix shift to Azure and other cloud services.  \n• Operating expenses increased $2.8  billion or 16% driven by investments in Azure and other cloud services.  \nRevenue and operating income included an unfavorable foreign currency impact of 2% and 3%, respectively.  \nMore Personal Computing  \nRevenue increased $5.6  billion or 10%.  \n• Windows revenue increased $2.3  billion or 10% driven by growth in Windows OEM and Windows \nCommercial. Windows OEM revenue increased 11% driven by continued strength in the commercial PC \nmarket, which has higher revenue per license. Windows Commercial products and cloud services revenue \nincreased 11% driven by demand for Microsoft 365.', 'score': 0.19030862}, {'text': '34 net income tax benefit related to an India Supreme Court decision on withholding taxes in the third quarter of fiscal year \n2021. Refer to the Non -GAAP Financial Measures section below for a reconciliation of our financial results reported in \naccordance with GAAP to non -GAAP financial results. See Note 12 – Income Taxes of the Notes to Financial Statements \nin our fiscal year 2022 Form 10 -K for further discussion.  \nFiscal Year 2022 Compared with Fiscal Year 2021  \nRevenue increased $30.2  billion or 18% driven by growth across each of our segments. Intelligent Cloud revenue \nincreased driven by Azure and other cloud services. Productivity and Business Processes revenue increased driven by \nOffice 365 Commercial and LinkedIn. More Personal Computing revenue increased driven by Search and news \nadvertising and Windows.  \nCost of revenue increased $10.4  billion or 20% driven by growth in Microsoft Cloud.  \nGross margin increased $19.8  billion or 17% driven by growth across each of our segments.  \n• Gross margin percentage decreased slightly. Excluding the impact of the fiscal year 2021 change in \naccounting estimate for the useful lives of our server and network equipment, gross margin percentage \nincreased 1 point driven by improvement in Productivity and Business Processes.  \n• Microsoft Cloud gross margin percentage decreased slightly to 70%. Excluding the impact of the change in \naccounting estimate, Microsoft Cloud gross margin percentage increased 3 points driven by improvement \nacross our cloud services, offset in part by sales mix shift to Azure and other cloud services.  \nOperating expenses increased $6.3  billion or 14% driven by investments in cloud engineering, LinkedIn, Gaming, and \ncommercial sales.  \nKey changes in operating expenses were:  \n• Research and development expenses increased $3.8  billion or 18% driven by investments in cloud \nengineering, Gaming, and LinkedIn.  \n• Sales and marketing expenses increased $1.7  billion or 8% driven by investments in commercial sales and \nLinkedIn. Sales and marketing included a favorable foreign currency impact of 2%.  \n• General and administrative expenses increased $793  million or 16% driven by investments in corporate \nfunctions.  \nOperating income increased $13.5  billion or 19% driven by growth across each of our segments.  \nCurrent year net income and diluted EPS were positively impacted by the net tax benefit related to the transfer of \nintangible properties, which resulted in an increase to net income and diluted EPS of $3.3  billion and $0.44, respectively. \nPrior year net income and diluted EPS were positively impacted by the net tax benefit related to the India Supreme Court \ndecision on withholding taxes, which resulted in an increase to net income and diluted EPS of $620  million and $0.08, \nrespectively.  \nGross margin and operating income both included an unfavorable foreign currency impact of 2%.  \nSEGMENT RESULTS OF OPERATIONS  \n  \n(In millions, except percentages)  2022  2021  Percentage  \nChange    \n        \nRevenue        \n        \nProductivity and Business Processes  $ 63,364   $ 53,915    18%  \nIntelligent Cloud   75,251    60,080    25%  \nMore Personal Computing   59,655    54,093    10%        \nTotal  $   198,270   $  168,088    18%          \n        \nOperating Income        \n        \nProductivity and Business Processes  $ 29,687   $ 24,351    22%  \nIntelligent Cloud   32,721    26,126    25%  \nMore Personal Computing   20,975    19,439    8%        \nTotal  $ 83,383   $ 69,916    19%', 'score': 0.04015541}, {'text': '31   \nIndustry Trends  \nOur industry is dynamic and highly competitive, with frequent changes in both technologies and business models. Each \nindustry shift is an opportunity to conceive new products, new technologies, or new ideas that can further transform the \nindustry and our business. At Microsoft, we push the boundaries of what is possible through a broad range of research \nand development activities that seek to identify and address the changing demands of customers and users, industry \ntrends, and competitive forces.  \nEconomic Conditions, Challenges, and Risks  \nThe markets for software, devices, and cloud -based services are dynamic and highly competitive. Our competitors are \ndeveloping new software and devices, while also deploying competing cloud -based services for consumers and \nbusinesses. The devices and form factors customers prefer evolve rapidly, and influence how users access services in \nthe cloud, and in some cases, the user’s choice of which suite of cloud -based services to use. We must continue to evolve \nand adapt over an extended time in pace with this changing environment. The investments we are making in infrastructure \nand devices will continue to increase our operating costs and may decrease our operating margins.  \nOur success is highly dependent on our ability to attract and retain qualified employees. We hire a mix of university and \nindustry talent worldwide. We compete for talented individuals globally by offering an exceptional working environment, \nbroad customer reach, scale in resources, the ability to grow one’s career across many different products and businesses, \nand competitive compensation and benefits. Aggregate demand for our software, services, and devices is correlated to \nglobal macroeconomic and geopolitical factors, which remain dynamic.  \nOur devices are primarily manufactured by third -party contract manufacturers, some of which contain certain components \nfor which there are very few qualified suppliers. For these components, we have limited near -term flexibility to use other \nmanufacturers if a current vendor becomes unavailable or is unable to meet our requirements. Extended disruptions at \nthese suppliers and/or manufacturers could lead to a similar disruption in our ability to manufacture devices on time to \nmeet consumer demand.  \nOur international operations provide a significant portion of our total revenue and expenses. Many of these revenue and \nexpenses are denominated in currencies other than the U.S. dollar. As a result, changes in foreign exchange rates may \nsignificantly affect revenue and expenses. Fluctuations in the U.S. dollar relative to certain foreign currencies did not hav e \na material impact on reported revenue or expenses from our international operations in fiscal year 2022.  \nRefer to Risk Factors in our fiscal year 2022 Form 10 -K for a discussion of these factors and other risks.  \nSeasonality  \nOur revenue fluctuates quarterly and is generally higher in the second and fourth quarters of our fiscal year. Second \nquarter revenue is driven by corporate year -end spending trends in our major markets and holiday season spending by \nconsumers, and fourth quarter revenue is driven by the volume of multi -year on -premises contracts executed during the \nperiod.  \nReportable Segments  \nWe report our financial performance based on the following segments: Productivity and Business Processes, Intelligent \nCloud, and More Personal Computing. The segment amounts included in MD&A are presented on a basis consistent with \nour internal management reporting. Additional information on our reportable segments is contained in Note 19 – Segment \nInformation and Geographic Data of the Notes to Financial Statements in our fiscal year 2022 Form 10 -K.  \nMetrics  \nWe use metrics in assessing the performance of our business and to make informed decisions regarding the allocation of', 'score': 0.0031708966}, {'text': '33 Dynamics products and cloud services revenue growth  Revenue from Dynamics products and cloud services, \nincluding Dynamics 365, comprising a set of intelligent, \ncloud -based applications across ERP, CRM, Customer \nInsights, Power Apps, and Power Automate; and on -\npremises ERP and CRM applications  \n    \nLinkedIn revenue growth  Revenue from LinkedIn, including Talent Solutions, \nMarketing Solutions, Premium Subscriptions, and Sales \nSolutions  \n    \nServer products and cloud services revenue growth  Revenue from Server products and cloud services, \nincluding Azure and other cloud services; SQL Server, \nWindows Server, Visual Studio, System Center, and \nrelated Client Access Licenses (“CALs”); and Nuance and \nGitHub  \nMore Personal Computing  \nMetrics related to our More Personal Computing segment assess the performance of key lines of business within this \nsegment. These metrics provide strategic product insights which allow us to assess the performance across our \ncommercial and consumer businesses. As we have diversity of target audiences and sales motions within the Windows \nbusiness, we monitor metrics that are reflective of those varying motions.  \n  \nWindows OEM revenue growth  Revenue from sales of Windows Pro and non -Pro licenses sold \nthrough the OEM channel  \n    \nWindows Commercial products and cloud \nservices revenue growth  Revenue from Windows Commercial products and cloud services, \ncomprising volume licensing of the Windows operating system, \nWindows cloud services, and other Windows commercial offerings  \n    \nSurface revenue growth  Revenue from Surface devices and accessories  \n    \nXbox content and services revenue growth  Revenue from Xbox content and services, comprising first - and third -\nparty content (including games and in -game content), Xbox Game \nPass and other subscriptions, Xbox Cloud Gaming, third -party disc \nroyalties, advertising, and other cloud services  \n    \nSearch and news advertising revenue, \nexcluding TAC, growth  Revenue from search and news advertising excluding traffic \nacquisition costs (“TAC”) paid to Bing Ads network publishers and \nnews partners  \nSUMMARY RESULTS OF OPERATIONS  \n  \n(In millions,  except  percentages  and per share  amounts)  2022  2021  Percentage  \nChange    \n        \nRevenue  $  198,270   $  168,088    18%  \nGross margin   135,620    115,856    17%  \nOperating income   83,383    69,916    19%  \nNet income   72,738    61,271    19%  \nDiluted earnings per share   9.65   8.05   20%  \n        \nAdjusted net income (non -GAAP)   69,447    60,651    15%  \nAdjusted diluted earnings per share (non -GAAP)   9.21   7.97   16%    \nAdjusted net income and adjusted diluted earnings per share (“EPS”) are non -GAAP financial measures which exclude \nthe net  income tax benefit related to transfer of intangible properties in the first quarter of fiscal year 2022 and the', 'score': 0.00047622027}]

This is how you can use this methods & pass this data to llm & get better results fro your RAG applications